mongodb

package
v0.0.0-...-9d01a2e Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MongoDB

type MongoDB struct {
	Client    *mongo.Client
	C         *mongo.Database
	Aggregate bool
	// contains filtered or unexported fields
}

func NewMongoDb

func NewMongoDb(uri string, dbname string, transactions bool, findandmodify bool) (*MongoDB, error)

func (*MongoDB) CommitTrx

func (db *MongoDB) CommitTrx() error

func (*MongoDB) CreateIndexes

func (db *MongoDB) CreateIndexes() error

func (*MongoDB) CreateOrder

func (db *MongoDB) CreateOrder(orderId int, customerId int, warehouseId int, districtId int, oCarrierId int, oOlCnt int, allLocal int, orderEntryDate time.Time, orderLine []models.OrderLine) error

func (*MongoDB) CreateSchema

func (db *MongoDB) CreateSchema() error

func (*MongoDB) DeleteNewOrder

func (db *MongoDB) DeleteNewOrder(orderId int, warehouseId int, districtId int) error

func (*MongoDB) GetCustomer

func (db *MongoDB) GetCustomer(customerId int, warehouseId int, districtId int) (*models.Customer, error)

func (*MongoDB) GetCustomerById

func (db *MongoDB) GetCustomerById(customerId int, warehouseId int, districtId int) (*models.Customer, error)

func (*MongoDB) GetCustomerByName

func (db *MongoDB) GetCustomerByName(name string, warehouseId int, districtId int) (*models.Customer, error)

func (*MongoDB) GetCustomerIdOrder

func (db *MongoDB) GetCustomerIdOrder(orderId int, warehouseId int, districtId int) (int, error)

GetCId

func (*MongoDB) GetDistrict

func (db *MongoDB) GetDistrict(warehouseId int, districtId int) (*models.District, error)

func (*MongoDB) GetItems

func (db *MongoDB) GetItems(itemIds []int) (*[]models.Item, error)

todo: sharding

func (*MongoDB) GetLastOrder

func (db *MongoDB) GetLastOrder(customerId int, warehouseId int, districtId int) (*models.Order, error)

func (*MongoDB) GetNewOrder

func (db *MongoDB) GetNewOrder(warehouseId int, districtId int) (*models.NewOrder, error)

It also deletes new order, as MongoDB can do that findAndModify is set to 0

func (*MongoDB) GetNextOrderId

func (db *MongoDB) GetNextOrderId(warehouseId int, districtId int) (int, error)

func (*MongoDB) GetOrderLines

func (db *MongoDB) GetOrderLines(orderId int, warehouseId int, districtId int) (*[]models.OrderLine, error)

func (*MongoDB) GetStockCount

func (db *MongoDB) GetStockCount(orderIdLt int, orderIdGt int, threshold int, warehouseId int, districtId int) (int64, error)

func (*MongoDB) GetStockInfo

func (db *MongoDB) GetStockInfo(districtId int, iIds []int, iWids []int, allLocal int) (*[]models.Stock, error)

func (*MongoDB) GetWarehouse

func (db *MongoDB) GetWarehouse(warehouseId int) (*models.Warehouse, error)

func (*MongoDB) IncrementDistrictOrderId

func (db *MongoDB) IncrementDistrictOrderId(warehouseId int, districtId int) error

Get District using warehouseId and districtId and return pointer to models.District or error instead.

func (*MongoDB) InsertBatch

func (db *MongoDB) InsertBatch(tableName string, d []interface{}) error

func (*MongoDB) InsertHistory

func (db *MongoDB) InsertHistory(warehouseId int, districtId int, date time.Time, amount float64, data string) error

func (*MongoDB) InsertOne

func (db *MongoDB) InsertOne(tableName string, d interface{}) error

func (*MongoDB) RollbackTrx

func (db *MongoDB) RollbackTrx() error

func (*MongoDB) StartTrx

func (db *MongoDB) StartTrx() error

func (*MongoDB) SumOLAmount

func (db *MongoDB) SumOLAmount(orderId int, warehouseId int, districtId int) (float64, error)

func (*MongoDB) UpdateCredit

func (db *MongoDB) UpdateCredit(customerId int, warehouseId int, districtId int, balance float64, data string) error

func (*MongoDB) UpdateCustomer

func (db *MongoDB) UpdateCustomer(customerId int, warehouseId int, districtId int, sumOlTotal float64) error

func (*MongoDB) UpdateDistrictBalance

func (db *MongoDB) UpdateDistrictBalance(warehouseId int, districtId int, amount float64) error

func (*MongoDB) UpdateOrders

func (db *MongoDB) UpdateOrders(orderId int, warehouseId int, districtId int, oCarrierId int, deliveryDate time.Time) error

func (*MongoDB) UpdateStock

func (db *MongoDB) UpdateStock(stockId int, warehouseId int, quantity int, ytd int, ordercnt int, remotecnt int) error

func (*MongoDB) UpdateWarehouseBalance

func (db *MongoDB) UpdateWarehouseBalance(warehouseId int, amount float64) error

Jump to

Keyboard shortcuts

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