databases

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2020 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 Database

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

func NewMongoDb added in v0.0.2

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

func (*Database) CommitTrx added in v0.0.2

func (db *Database) CommitTrx() error

func (*Database) CreateIndexes

func (db *Database) CreateIndexes() error

func (*Database) CreateOrder added in v0.0.2

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

func (*Database) DeleteNewOrder added in v0.0.2

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

func (*Database) DoTrxRetries

func (db *Database) DoTrxRetries(fn func(ctx context.Context) error, retries int) error

func (*Database) GetCustomer added in v0.0.2

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

func (*Database) GetCustomerById added in v0.0.2

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

func (*Database) GetCustomerByName added in v0.0.2

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

func (*Database) GetCustomerIdOrder added in v0.0.2

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

GetCId

func (*Database) GetDistrict added in v0.0.2

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

func (*Database) GetItems added in v0.0.2

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

todo: sharding

func (*Database) GetLastOrder added in v0.0.2

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

func (*Database) GetNewOrder added in v0.0.2

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

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

func (*Database) GetNextOrderId added in v0.0.2

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

func (*Database) GetOrderLines added in v0.0.2

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

func (*Database) GetStockCount added in v0.0.2

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

func (*Database) GetStockInfo added in v0.0.2

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

func (*Database) GetWarehouse added in v0.0.2

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

func (*Database) IncrementDistrictOrderId added in v0.0.2

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

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

func (*Database) InsertBatch

func (db *Database) InsertBatch(collectionName string, d []interface{}) error

func (*Database) InsertHistory added in v0.0.2

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

func (*Database) InsertOne

func (db *Database) InsertOne(collectionName string, d interface{}) error

func (*Database) RollbackTrx added in v0.0.2

func (db *Database) RollbackTrx() error

func (*Database) StartTrx added in v0.0.2

func (db *Database) StartTrx() error

func (*Database) UpdateCredit added in v0.0.2

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

func (*Database) UpdateCustomer added in v0.0.2

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

func (*Database) UpdateDistrictBalance added in v0.0.2

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

func (*Database) UpdateOrders added in v0.0.2

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

func (*Database) UpdateStock added in v0.0.2

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

func (*Database) UpdateWarehouseBalance added in v0.0.2

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

Jump to

Keyboard shortcuts

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