Documentation
¶
Index ¶
- type DB
- func (db *DB) AddPayment(userID uint, amount int)
- func (db *DB) Close()
- func (db *DB) CreateNewUser(username string)
- func (db *DB) DeletePayment(paymentID uint)
- func (db *DB) DeletePurchase(purchaseID uint)
- func (db *DB) GetAllDrinks() []models.Drink
- func (db *DB) GetAllPaymentsOfUser(userID uint) []models.Payment
- func (db *DB) GetAllUsers() []models.User
- func (db *DB) GetNumberOfPurchasesOfUser(userID uint) int
- func (db *DB) GetPaginatedPurchasesOfUser(userID uint, itemsPerPage int, page int) []models.Purchase
- func (db *DB) GetPurchasesOfUser(userID uint) []models.Purchase
- func (db *DB) GetTotalDebtOfUser(userID uint) int
- func (db *DB) GetUsername(userID uint) string
- func (db *DB) PurchaseDrink(userID uint, drinkID uint)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
DB stores database connection
func (*DB) AddPayment ¶
AddPayment adds a payment for a user specified by id with a certain amount
func (*DB) CreateNewUser ¶
CreateNewUser creates a new user with given username
func (*DB) DeletePayment ¶
DeletePayment deletes a payment specified by its id
func (*DB) DeletePurchase ¶
DeletePurchase deletes a purchase from database
func (*DB) GetAllDrinks ¶
GetAllDrinks returns all drinks in the database
func (*DB) GetAllPaymentsOfUser ¶
GetAllPaymentsOfUser returns all payments of one user specified by id
func (*DB) GetAllUsers ¶
GetAllUsers returns all users currently in the database
func (*DB) GetNumberOfPurchasesOfUser ¶
GetNumberOfPurchasesOfUser returns the number of purchases by a given user
func (*DB) GetPaginatedPurchasesOfUser ¶
func (db *DB) GetPaginatedPurchasesOfUser(userID uint, itemsPerPage int, page int) []models.Purchase
GetPaginatedPurchasesOfUser returns purchases for a given user on a specific page (beginning with 1) with given numberOfItems on each page
func (*DB) GetPurchasesOfUser ¶
GetPurchasesOfUser returns all purchases of one user specified by user id with drink information preloaded
func (*DB) GetTotalDebtOfUser ¶
GetTotalDebtOfUser returns the total debt of one user specified by their user id
func (*DB) GetUsername ¶
GetUsername returns the username for a given user id
func (*DB) PurchaseDrink ¶
PurchaseDrink adds a purchase for one user specified by their id and a drink also specified by id