Documentation
¶
Index ¶
- Constants
- Variables
- type OrdersDataService
- type OrdersRepo
- func (o *OrdersRepo) Create(ctx context.Context, po *data.Order) (string, error)
- func (o *OrdersRepo) DeleteByID(ctx context.Context, id primitive.ObjectID) error
- func (o *OrdersRepo) GetAll(ctx context.Context, offset, limit int64) (*[]data.Order, error)
- func (o *OrdersRepo) GetByID(ctx context.Context, oID primitive.ObjectID) (*data.Order, error)
- func (o *OrdersRepo) Update(ctx context.Context, po *data.Order) error
Constants ¶
View Source
const ( OrdersCollection = "purchaseOrders" DefaultPageSize = 100 )
Variables ¶
View Source
var ( ErrInvalidInitialization = errors.New("invalid initialization") ErrInvalidPOIDCreate = errors.New("order id should be empty") ErrInvalidPOIDUpdate = errors.New("invalid order id") ErrUnexpectedUpdateOrder = errors.New("unexpected error occurred while updating order") ErrPOIDNotFound = errors.New("purchase order doesn't exist with given id") ErrFailedToCreateOrder = errors.New("failed to create order") ErrUnexpectedDeleteOrder = errors.New("unexpected error occurred while deleting order") ErrUnexpectedGetOrder = errors.New("unexpected error occurred while fetching order") ErrInvalidID = errors.New("failed to assert inserted ID as ObjectID") )
Functions ¶
This section is empty.
Types ¶
type OrdersDataService ¶
type OrdersDataService interface {
Create(ctx context.Context, purchaseOrder *data.Order) (string, error)
Update(ctx context.Context, purchaseOrder *data.Order) error
GetAll(ctx context.Context, offset, limit int64) (*[]data.Order, error)
GetByID(ctx context.Context, id primitive.ObjectID) (*data.Order, error)
DeleteByID(ctx context.Context, id primitive.ObjectID) error
}
OrdersDataService defines the interface for order data operations.
type OrdersRepo ¶
type OrdersRepo struct {
// contains filtered or unexported fields
}
OrdersRepo implements OrdersDataService using MongoDB.
func NewOrdersRepo ¶
func NewOrdersRepo(lgr logger.Logger, db mongodb.MongoDatabase) (*OrdersRepo, error)
NewOrdersRepo creates a new OrdersRepo.
func (*OrdersRepo) DeleteByID ¶
DeleteByID removes an order by its ObjectID.
func (*OrdersRepo) GetAll ¶
GetAll retrieves all orders up to the specified limit, starting at the given offset.
Click to show internal directories.
Click to hide internal directories.