db

package
v0.0.0-...-0268f66 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

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

func MigrateTo

func MigrateTo(ctx context.Context, connectionURL string, version string) (err error)

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 (repo Repository) InsertVehicle(ctx context.Context, vehicle domain.Vehicle) error

func (Repository) ListVehicles

func (repo Repository) ListVehicles(ctx context.Context, arg domain.ListVehiclesParams) (page domain.Page[domain.Vehicle], err error)

func (Repository) UpdateVehicle

func (repo Repository) UpdateVehicle(ctx context.Context, vehicle domain.Vehicle) error

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"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL