db

package
v0.0.0-...-4605876 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DbServiceImpl

type DbServiceImpl struct {
	// contains filtered or unexported fields
}

DbServiceImpl is an implementation of the database repository It is implementation agnostic i.e logic should be handled using the preferred database

func NewDBService

func NewDBService(c gorm.Create, q gorm.Query, u gorm.Update) *DbServiceImpl

NewDBService creates a new database service

func (*DbServiceImpl) AddProduct

func (d *DbServiceImpl) AddProduct(ctx context.Context, product *domain.Product) (*domain.Product, error)

Adds a product into the database

func (*DbServiceImpl) AddSaleRecord

func (d *DbServiceImpl) AddSaleRecord(ctx context.Context, sale *domain.Sale) (*domain.Sale, error)

AddSaleRecord adds sale record in the database

func (*DbServiceImpl) GetDailySale

func (d *DbServiceImpl) GetDailySale(ctx context.Context) ([]*domain.Sale, error)

GetDailySale retrieves daily sales

func (*DbServiceImpl) GetProductByID

func (d *DbServiceImpl) GetProductByID(ctx context.Context, id string) (*domain.Product, error)

GetProductByID retrieves a product using its ID

func (*DbServiceImpl) GetUserPINByUserID

func (d *DbServiceImpl) GetUserPINByUserID(ctx context.Context, userID string, flavour enums.Flavour) (*domain.UserPIN, error)

GetUserPINByUserID fetches and returns a user PIN using their user ID

func (*DbServiceImpl) GetUserProfileByPhoneNumber

func (d *DbServiceImpl) GetUserProfileByPhoneNumber(ctx context.Context, phoneNumber string, flavour enums.Flavour) (*domain.User, error)

GetUserProfileByPhoneNumber fetches and returns a userprofile using their phone number

func (*DbServiceImpl) GetUserProfileByUserID

func (d *DbServiceImpl) GetUserProfileByUserID(ctx context.Context, userID string) (*domain.User, error)

GetUserProfileByUserID fetches and returns a userprofile using their user ID

func (*DbServiceImpl) InvalidatePIN

func (d *DbServiceImpl) InvalidatePIN(ctx context.Context, userID string, flavour enums.Flavour) error

InvalidatePIN invalidates a pin that is linked to the user profile. This is done by toggling the IsValid field to false

func (*DbServiceImpl) RegisterUser

func (d *DbServiceImpl) RegisterUser(ctx context.Context, user *domain.User, contact *domain.Contact) (*domain.User, error)

RegisterUser registers a new user in the database

func (*DbServiceImpl) SaveOTP

func (d *DbServiceImpl) SaveOTP(ctx context.Context, otp *domain.OTP) (*domain.OTP, error)

SaveOTP saves an OTP in the database

func (*DbServiceImpl) SavePIN

func (d *DbServiceImpl) SavePIN(ctx context.Context, pinInput *domain.UserPIN) (*domain.UserPIN, error)

SavePIN saves a PIN in the database

func (*DbServiceImpl) SearchProduct

func (d *DbServiceImpl) SearchProduct(ctx context.Context, searchTerm string) (*domain.Product, error)

SearchProduct searches a product using the term provided by the user

func (*DbServiceImpl) SearchUser

func (d *DbServiceImpl) SearchUser(ctx context.Context, searchTerm string) ([]*domain.User, error)

SearchUser searches for users in the system using a search term

func (*DbServiceImpl) UpdateProduct

func (d *DbServiceImpl) UpdateProduct(ctx context.Context, product *domain.Product, updateData map[string]interface{}) error

UpdateProduct updates product details in the database

func (*DbServiceImpl) UpdateUser

func (d *DbServiceImpl) UpdateUser(ctx context.Context, user *domain.User, updateData map[string]interface{}) error

UpdateUser updates a user record

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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