database

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Copyright 2023 PraserX

Copyright 2023 PraserX

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close()

Close gracefully end up connection to database.

func DepositMoney added in v1.4.0

func DepositMoney(uid uint, amount float32) error

func Get

func Get() *gorm.DB

Get returns database instance.

func InsertBill

func InsertBill(bill models.Bill) (int, error)

func InsertPeriod

func InsertPeriod(period models.Period) (int, error)

InsertUser inserts user into the database and returns ID of the inserted record and error if any occurs.

func InsertSchema added in v1.1.0

func InsertSchema(schema models.Schema) (int, error)

func InsertTransaction added in v1.4.0

func InsertTransaction(transaction models.Transaction) (int, error)

func InsertUser

func InsertUser(user models.User) (int, error)

InsertUser inserts user into the database and returns ID of the inserted record and error if any occurs.

func RunAutoMigration

func RunAutoMigration() error

RunAutoMigration creates all required tables in database.

func SelectAllBills added in v1.2.0

func SelectAllBills() (bills []models.Bill, err error)

func SelectAllBillsForPeriod

func SelectAllBillsForPeriod(pid uint) ([]models.Bill, error)

func SelectAllBillsForUser added in v1.2.0

func SelectAllBillsForUser(uid uint) ([]models.Bill, error)

func SelectAllBillsForUserExceptSpecifiedPeriod added in v1.2.0

func SelectAllBillsForUserExceptSpecifiedPeriod(uid, pid uint) ([]models.Bill, error)

func SelectAllPeriods added in v1.3.0

func SelectAllPeriods() ([]models.Period, error)

func SelectAllPeriodsExceptSpecifiedPeriod added in v1.2.0

func SelectAllPeriodsExceptSpecifiedPeriod(pid uint) ([]models.Period, error)

func SelectAllTransactions added in v1.4.0

func SelectAllTransactions() ([]models.Transaction, error)

func SelectAllTransactionsForUser added in v1.4.0

func SelectAllTransactionsForUser(uid uint) ([]models.Transaction, error)

func SelectAllUsers

func SelectAllUsers() (users []models.User, err error)

func SelectBillByID

func SelectBillByID(id uint) (bill models.Bill, err error)

func SelectPeriodByID

func SelectPeriodByID(id uint) (period models.Period, err error)

func SelectUserByEID

func SelectUserByEID(eid string) (user models.User, err error)

func SelectUserByEmail

func SelectUserByEmail(email string) (user models.User, err error)

func SelectUserByID

func SelectUserByID(id uint) (user models.User, err error)

func SelectVersion added in v1.1.0

func SelectVersion() (schema models.Schema, err error)

func SetupDatabase

func SetupDatabase(opts ...Option)

SetupDatabase set ups database with defined arguments and initialize global instance.

func UpdateBillOnIssued

func UpdateBillOnIssued(bid uint) error

func UpdateBillOnPaid

func UpdateBillOnPaid(bid uint) error

func UpdateBillOnPaymentConfirmation added in v1.2.0

func UpdateBillOnPaymentConfirmation(bid uint) error

func UpdateBillOnPeriodClose

func UpdateBillOnPeriodClose(bid uint, amount, payment float32) error

func UpdatePeriodOnClose

func UpdatePeriodOnClose(pid uint, totalQuantity int, unitPrice float32) error

func UpdateUserName added in v1.3.0

func UpdateUserName(uid uint, firstname, lastname string) error

func UpdateVersion added in v1.1.0

func UpdateVersion(version uint) error

func WithdrawMoney added in v1.4.0

func WithdrawMoney(uid uint, amount float32) error

Types

type DatabaseOptions

type DatabaseOptions struct {
	Path string
}

Options are used for Database construct function.

type Option

type Option func(*DatabaseOptions)

Option definition

func WithPath

func WithPath(path string) Option

WithPath option specification.

Jump to

Keyboard shortcuts

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