func EmployeeTerritoryByEmployeeIDTerritoryID(ctx context.Context, db DB, employeeID int16, territoryID string) (*EmployeeTerritory, error) {
	const sqlstr = `SELECT ` +
		`employee_id, territory_id ` +
		`FROM public.employee_territories ` +
		`WHERE employee_id = $1 AND territory_id = $2`
	logf(sqlstr, employeeID, territoryID)
	et := EmployeeTerritory{
		_exists: true,
	}
	if err := db.QueryRowContext(ctx, sqlstr, employeeID, territoryID).Scan(&et.EmployeeID, &et.TerritoryID); err != nil {
		return nil, logerror(err)
	}
	return &et, nil
}
EmployeeTerritoryByEmployeeIDTerritoryID retrieves a row from 'public.employee_territories' as a EmployeeTerritory.

Generated from index 'employee_territories_pkey'.
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
}
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
}
func (et *EmployeeTerritory) Delete(ctx context.Context, db DB) error {
	switch {
	case !et._exists:  
		return nil
	case et._deleted:  
		return nil
	}
	const sqlstr = `DELETE FROM public.employee_territories WHERE employee_id = $1 AND territory_id = $2`
	logf(sqlstr, et.EmployeeID, et.TerritoryID)
	if _, err := db.ExecContext(ctx, sqlstr, et.EmployeeID, et.TerritoryID); err != nil {
		return logerror(err)
	}
	et._deleted = true
	return nil
}