Documentation ¶
Index ¶
- Constants
- type DB
- type MongoDB
- func (m *MongoDB) Close() error
- func (m *MongoDB) Connect(ctx context.Context) error
- func (m *MongoDB) GetOrders(ctx context.Context, result *[]OrderStatus) error
- func (m *MongoDB) GetShipments(ctx context.Context, result *[]ShipmentStatus) error
- func (m *MongoDB) InsertOrder(ctx context.Context, order *OrderStatus) error
- func (m *MongoDB) Setup() error
- func (m *MongoDB) UpdateOrderStatus(ctx context.Context, id string, status string) error
- func (m *MongoDB) UpdateShipmentStatus(ctx context.Context, id string, status string) error
- type OrderStatus
- type SQLiteDB
- func (s *SQLiteDB) Close() error
- func (s *SQLiteDB) Connect(_ context.Context) error
- func (s *SQLiteDB) GetOrders(ctx context.Context, result *[]OrderStatus) error
- func (s *SQLiteDB) GetShipments(ctx context.Context, result *[]ShipmentStatus) error
- func (s *SQLiteDB) InsertOrder(ctx context.Context, order *OrderStatus) error
- func (s *SQLiteDB) Setup() error
- func (s *SQLiteDB) UpdateOrderStatus(ctx context.Context, id string, status string) error
- func (s *SQLiteDB) UpdateShipmentStatus(ctx context.Context, id string, status string) error
- type ShipmentStatus
Constants ¶
const OrdersCollection = "orders"
OrdersCollection is the name of the MongoDB collection to use for Orders.
const ShipmentCollection = "shipments"
ShipmentCollection is the name of the MongoDB collection to use for Shipment data.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB interface { Connect(ctx context.Context) error Setup() error Close() error InsertOrder(context.Context, *OrderStatus) error UpdateOrderStatus(context.Context, string, string) error GetOrders(context.Context, *[]OrderStatus) error UpdateShipmentStatus(context.Context, string, string) error GetShipments(context.Context, *[]ShipmentStatus) error }
DB is an interface that defines the methods that a database driver must implement
type MongoDB ¶
type MongoDB struct {
// contains filtered or unexported fields
}
MongoDB is a struct that implements the DB interface for MongoDB
func (*MongoDB) GetOrders ¶
func (m *MongoDB) GetOrders(ctx context.Context, result *[]OrderStatus) error
GetOrders returns a list of Orders from the MongoDB instance
func (*MongoDB) GetShipments ¶
func (m *MongoDB) GetShipments(ctx context.Context, result *[]ShipmentStatus) error
GetShipments returns a list of Shipments from the MongoDB instance
func (*MongoDB) InsertOrder ¶
func (m *MongoDB) InsertOrder(ctx context.Context, order *OrderStatus) error
InsertOrder inserts an Order into the MongoDB instance
func (*MongoDB) UpdateOrderStatus ¶
UpdateOrderStatus updates an Order in the MongoDB instance
type OrderStatus ¶
type OrderStatus struct { ID string `db:"id" bson:"id"` CustomerID string `db:"customer_id" bson:"customer_id"` Status string `db:"status" bson:"status"` ReceivedAt time.Time `db:"received_at" bson:"received_at"` }
OrderStatus is a struct that represents the status of an Order
type SQLiteDB ¶
type SQLiteDB struct {
// contains filtered or unexported fields
}
SQLiteDB is a struct that implements the DB interface for SQLite
func (*SQLiteDB) GetOrders ¶
func (s *SQLiteDB) GetOrders(ctx context.Context, result *[]OrderStatus) error
GetOrders returns a list of Orders from the SQLite instance
func (*SQLiteDB) GetShipments ¶
func (s *SQLiteDB) GetShipments(ctx context.Context, result *[]ShipmentStatus) error
GetShipments returns a list of Shipments from the SQLite instance
func (*SQLiteDB) InsertOrder ¶
func (s *SQLiteDB) InsertOrder(ctx context.Context, order *OrderStatus) error
InsertOrder inserts an Order into the SQLite instance
func (*SQLiteDB) UpdateOrderStatus ¶
UpdateOrderStatus updates an Order in the SQLite instance
type ShipmentStatus ¶
type ShipmentStatus struct { ID string `db:"id" bson:"id"` Status string `db:"status" bson:"status"` }
ShipmentStatus is a struct that represents the status of a Shipment