dbrepo

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 License: GPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PostgresDBRepo

type PostgresDBRepo struct {
	DB *sql.DB
}

PostgresDBRepo is the struct used to wrap our database connection pool, so that we can easily swap out a real database for a test database, or move to another database entirely, as long as the thing being swapped implements all of the functions in the type repository.DatabaseRepo.

func (*PostgresDBRepo) CheckOrderExist

func (m *PostgresDBRepo) CheckOrderExist(cartID int, productID int) (bool, error)

CheckOrderExist checks order exist based on cart id and product id.

func (*PostgresDBRepo) Connection

func (m *PostgresDBRepo) Connection() *sql.DB

Connection returns underlying connection pool.

func (*PostgresDBRepo) CreateCartForNewUser

func (m *PostgresDBRepo) CreateCartForNewUser(userID int) (int, error)

func (*PostgresDBRepo) DeleteOder

func (m *PostgresDBRepo) DeleteOder(orderID int) error

DeleteOder deletes order with id.

func (*PostgresDBRepo) GetCategories

func (m *PostgresDBRepo) GetCategories() ([]*models.Category, error)

func (*PostgresDBRepo) GetOrderByUserEmail

func (m *PostgresDBRepo) GetOrderByUserEmail(email string) ([]*models.ProductOrder, error)

GetOrderByUserEmail returns products in specific user cart.

func (*PostgresDBRepo) GetPaymentByUserEmail

func (m *PostgresDBRepo) GetPaymentByUserEmail(email string) ([]*models.ProductPayment, error)

func (*PostgresDBRepo) GetProductByCategory

func (m *PostgresDBRepo) GetProductByCategory(id int) ([]*models.Product, error)

func (*PostgresDBRepo) GetProducts

func (m *PostgresDBRepo) GetProducts() ([]*models.Product, error)

func (*PostgresDBRepo) GetUserByEmail

func (m *PostgresDBRepo) GetUserByEmail(email string) (*models.User, error)

GetUserByEmail returns one user, by email.

func (*PostgresDBRepo) GetUserCartByEmail

func (m *PostgresDBRepo) GetUserCartByEmail(email string) (int, error)

func (*PostgresDBRepo) GetUserCartIDByEmail

func (m *PostgresDBRepo) GetUserCartIDByEmail(email string) (int, error)

GetUserCartIDByEmail return user cart_id.

func (*PostgresDBRepo) InsertOrder

func (m *PostgresDBRepo) InsertOrder(cartID int, productID int, quantity int) (int, error)

InsertOrder creates new order.

func (*PostgresDBRepo) InsertSuccessPayment

func (m *PostgresDBRepo) InsertSuccessPayment(userID int, productID int, quantity int) (int, error)

func (*PostgresDBRepo) InsertUser

func (m *PostgresDBRepo) InsertUser(user *models.User) (int, error)

InsertUser creates new user.

func (*PostgresDBRepo) UpdateQuantity

func (m *PostgresDBRepo) UpdateQuantity(cartID int, productID int, quantityToAdd int) (int, error)

UpdateQuantity adds more quantity from the same order.

Jump to

Keyboard shortcuts

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