mongo

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CarRecord

type CarRecord struct {
	mgutil.IDField `bson:"inline"`
	Car            *base.Car `bson:"car"`
}

CarRecord defines a car record in mongo db.

type CarUpdate

type CarUpdate struct {
	Status       base.CarStatus
	Position     *base.Position
	Driver       *base.Driver
	Power        float64
	UpdateTripID bool
	TripID       id.TripID
	PlateNum     string
}

CarUpdate defines updates to a car. Only specified fields will be updated.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(db *mongo.Database) *Manager

NewManager creates a mongo manager.

func (*Manager) CreateCar

func (m *Manager) CreateCar(c context.Context, plateNum string) (*CarRecord, error)

CreateCar creates a car.

func (*Manager) DeleteCar

func (m *Manager) DeleteCar(c context.Context, id id.CarID) error

func (*Manager) GetCar

func (m *Manager) GetCar(c context.Context, id id.CarID) (*CarRecord, error)

GetCar gets a car.

func (*Manager) GetCars

func (m *Manager) GetCars(c context.Context, limit int64) ([]*CarRecord, error)

GetCars gets cars.

func (*Manager) UpdateCar

func (m *Manager) UpdateCar(c context.Context, id id.CarID, status base.CarStatus, update *CarUpdate) (*CarRecord, error)

UpdateCar updates a car. If status is specified, it updates the car only when existing record matches the status specified.

Jump to

Keyboard shortcuts

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