Documentation ¶
Index ¶
- Variables
- func MigrateTo(ctx context.Context, connectionURL string, version string) (err error)
- type DBConnection
- type Repository
- func (repo Repository) FetchVehicle(ctx context.Context, params domain.FetchVehicleParams) (vehicle domain.Vehicle, err error)
- func (repo Repository) InsertVehicle(ctx context.Context, vehicle domain.Vehicle) error
- func (repo Repository) ListVehicles(ctx context.Context, arg domain.ListVehiclesParams) (page domain.Page[domain.Vehicle], err error)
- func (repo Repository) UpdateVehicle(ctx context.Context, vehicle domain.Vehicle) error
- func (repo Repository) WithinTransaction(ctx context.Context, op func(pgx.Tx) error) (err error)
- type VehicleDTO
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrConflict = errors.New("already exists")
View Source
var ErrNotFound = errors.New("not found")
View Source
var Migrations embed.FS
Functions ¶
Types ¶
type DBConnection ¶
type DBConnection interface { Begin(ctx context.Context) (pgx.Tx, error) Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error) Query(ctx context.Context, sql string, optionsAndArgs ...any) (pgx.Rows, error) QueryRow(ctx context.Context, sql string, optionsAndArgs ...any) pgx.Row LoadType(ctx context.Context, typeName string) (*pgtype.Type, error) TypeMap() *pgtype.Map }
type Repository ¶
type Repository struct {
DBConnection
}
func NewRepository ¶
func NewRepository(ctx context.Context, conn DBConnection) (Repository, error)
func (Repository) FetchVehicle ¶
func (repo Repository) FetchVehicle(ctx context.Context, params domain.FetchVehicleParams) (vehicle domain.Vehicle, err error)
func (Repository) InsertVehicle ¶
func (Repository) ListVehicles ¶
func (repo Repository) ListVehicles(ctx context.Context, arg domain.ListVehiclesParams) (page domain.Page[domain.Vehicle], err error)
func (Repository) UpdateVehicle ¶
func (Repository) WithinTransaction ¶
func (repo Repository) WithinTransaction(ctx context.Context, op func(pgx.Tx) error) (err error)
type VehicleDTO ¶
type VehicleDTO struct { ID uuid.UUID `db:"id"` ExternalID string `db:"external_id"` Provider uuid.UUID `db:"provider"` DataProvider uuid.UUID `db:"data_provider"` VehicleType string `db:"vehicle_type"` PropulsionTypes []string `db:"propulsion_types"` Attributes domain.Record `db:"attributes"` AccessibilityAttributes domain.Record `db:"accessibility_attributes"` BatteryCapacity int32 `db:"battery_capacity"` FuelCapacity int32 `db:"fuel_capacity"` MaximumSpeed int32 `db:"maximum_speed"` }
Click to show internal directories.
Click to hide internal directories.