database

package
v0.0.0-...-24518c4 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2022 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	SQL *gorm.DB
}

func New

func New(dbPath string) (*DB, error)

Creates a new database connection

func (*DB) AddOrder

func (db *DB) AddOrder(order *order.Order) (uint, error)

Adds the given order to the database and returns its ID

func (*DB) AddUser

func (db *DB) AddUser(telegramID int64) error

Inserts a new user with the given fields to the database

func (*DB) DeleteOrder

func (db *DB) DeleteOrder(orderID uint) error

Deletes the order with the given ID

func (*DB) GetOrders

func (db *DB) GetOrders() ([]*order.Order, error)

Queries the database and returns an slice of all the orders

func (*DB) GetOrdersByUser

func (db *DB) GetOrdersByUser(telegramID int64) ([]*order.Order, error)

Queries the database and returns a slice of orders matching the user

func (*DB) GetUser

func (db *DB) GetUser(id uint) (*model.User, error)

Returns the user with the corresponding ID

func (*DB) GetUserFromTelegramID

func (db *DB) GetUserFromTelegramID(telegramID int64) (*model.User, error)

Searches a user in the database based on the telegram ID

func (*DB) Migrate

func (db *DB) Migrate() error

Migrates the database

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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