Documentation ¶
Index ¶
- type PostgresDBRepo
- func (m *PostgresDBRepo) CheckOrderExist(cartID int, productID int) (bool, error)
- func (m *PostgresDBRepo) Connection() *sql.DB
- func (m *PostgresDBRepo) CreateCartForNewUser(userID int) (int, error)
- func (m *PostgresDBRepo) DeleteOder(orderID int) error
- func (m *PostgresDBRepo) GetCategories() ([]*models.Category, error)
- func (m *PostgresDBRepo) GetOrderByUserEmail(email string) ([]*models.ProductOrder, error)
- func (m *PostgresDBRepo) GetPaymentByUserEmail(email string) ([]*models.ProductPayment, error)
- func (m *PostgresDBRepo) GetProductByCategory(id int) ([]*models.Product, error)
- func (m *PostgresDBRepo) GetProducts() ([]*models.Product, error)
- func (m *PostgresDBRepo) GetUserByEmail(email string) (*models.User, error)
- func (m *PostgresDBRepo) GetUserCartByEmail(email string) (int, error)
- func (m *PostgresDBRepo) GetUserCartIDByEmail(email string) (int, error)
- func (m *PostgresDBRepo) InsertOrder(cartID int, productID int, quantity int) (int, error)
- func (m *PostgresDBRepo) InsertSuccessPayment(userID int, productID int, quantity int) (int, error)
- func (m *PostgresDBRepo) InsertUser(user *models.User) (int, error)
- func (m *PostgresDBRepo) UpdateQuantity(cartID int, productID int, quantityToAdd int) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PostgresDBRepo ¶
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 ¶
InsertOrder creates new order.
func (*PostgresDBRepo) InsertSuccessPayment ¶
func (*PostgresDBRepo) InsertUser ¶
func (m *PostgresDBRepo) InsertUser(user *models.User) (int, error)
InsertUser creates new user.
func (*PostgresDBRepo) UpdateQuantity ¶
UpdateQuantity adds more quantity from the same order.