func (et *EmployeeTerritory) Insert(ctx context.Context, db DB) error {
	switch {
	case et._exists:  
		return logerror(&ErrInsertFailed{ErrAlreadyExists})
	case et._deleted:  
		return logerror(&ErrInsertFailed{ErrMarkedForDeletion})
	}
	const sqlstr = `INSERT INTO public.employee_territories (` +
		`employee_id, territory_id` +
		`) VALUES (` +
		`$1, $2` +
		`)`
	logf(sqlstr, et.EmployeeID, et.TerritoryID)
	if _, err := db.ExecContext(ctx, sqlstr, et.EmployeeID, et.TerritoryID); err != nil {
		return logerror(err)
	}
	et._exists = true
	return nil
}
Insert inserts the EmployeeTerritory to the database.
package models
import (
	"context"
)
type EmployeeTerritory struct {
	EmployeeID  int16  `json:"employee_id"`   
	TerritoryID string `json:"territory_id"`  
	_exists, _deleted bool
}
func (et *EmployeeTerritory) Exists() bool {
	return et._exists
}
func (et *EmployeeTerritory) Deleted() bool {
	return et._deleted
}