database

package
v0.0.0-...-e8ac103 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: MIT 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 interface {
	Close() error
	GetAllCustomers() ([]models.Customer, error)
	GetCustomerByID(uint) (models.Customer, error)
	GetProductsByIDs([]uint) ([]models.Product, error)
	CreateOrder(*models.Order) error
	GetOrderByID(uint) (models.Order, error)
	IsPreviousOrderUnfulfilled(uint) (bool, error)
	CreateCustomer(customer *models.Customer) error
	GetCustomerByEmail(string) (*models.Customer, error)
	CreateProduct(*models.Product) error
}

func ConnectDatabase

func ConnectDatabase(cfg *config.DatabaseConfig) (Database, error)

type PostgresDB

type PostgresDB struct {
	DB *gorm.DB
}

func (*PostgresDB) Close

func (db *PostgresDB) Close() error

func (*PostgresDB) CreateCustomer

func (db *PostgresDB) CreateCustomer(customer *models.Customer) error

func (*PostgresDB) CreateOrder

func (db *PostgresDB) CreateOrder(order *models.Order) error

func (*PostgresDB) CreateProduct

func (db *PostgresDB) CreateProduct(product *models.Product) error

func (*PostgresDB) GetAllCustomers

func (db *PostgresDB) GetAllCustomers() ([]models.Customer, error)

func (*PostgresDB) GetCustomerByEmail

func (db *PostgresDB) GetCustomerByEmail(email string) (*models.Customer, error)

func (*PostgresDB) GetCustomerByID

func (db *PostgresDB) GetCustomerByID(id uint) (models.Customer, error)

func (*PostgresDB) GetOrderByID

func (db *PostgresDB) GetOrderByID(orderID uint) (models.Order, error)

func (*PostgresDB) GetProductsByIDs

func (db *PostgresDB) GetProductsByIDs(productIDs []uint) ([]models.Product, error)

func (*PostgresDB) IsPreviousOrderUnfulfilled

func (db *PostgresDB) IsPreviousOrderUnfulfilled(customerID uint) (bool, error)

Jump to

Keyboard shortcuts

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