database

package
v0.0.0-...-84b6340 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdminValidateLogin

func AdminValidateLogin(ctx context.Context, h *Handler, username string, password string) (*models.Admin, error)

func CheckAdminEmailExist

func CheckAdminEmailExist(ctx context.Context, h *Handler, admin models.Admin) (bool, error)

CheckEmailExist is a function to check if the email already exists

func CheckAdminExist

func CheckAdminExist(ctx context.Context, h *Handler, admin models.Admin) (bool, error)

CheckAdminExist is a function to check if the Admin already exists

func CheckEmailExist

func CheckEmailExist(ctx context.Context, h *Handler, user models.User) (bool, error)

CheckEmailExist is a function to check if the email already exists

func CheckUserExist

func CheckUserExist(ctx context.Context, h *Handler, user models.User) (bool, error)

CheckUserExist is a function to check if the user already exists

func CloseMongo

func CloseMongo(db *mongo.Database, cancel context.CancelFunc) error

func ConnectMongo

func ConnectMongo(uri, dbName string, timeout time.Duration) (*mongo.Database, context.CancelFunc, error)

func CreateAdmin

func CreateAdmin(ctx context.Context, h *Handler, admin models.Admin) error

CreateAdmin is a function to create a new Admin

func CreateUser

func CreateUser(ctx context.Context, h *Handler, user models.User) error

CreateUser is a function to create a new user

func GetAdminByEmail

func GetAdminByEmail(ctx context.Context, h *Handler, email string) (*models.Admin, error)

GetAdminByEmail is a function to get an Admin by email

func GetAdminByUserID

func GetAdminByUserID(ctx context.Context, h *Handler, userID primitive.ObjectID) (*models.Admin, error)

GetAdminByUserID is a function to get an Admin by userID

func GetAdminByUsername

func GetAdminByUsername(ctx context.Context, h *Handler, username string) (*models.Admin, error)

GetAdminByUsername is a function to get an Admin by username

func ValidateLogin

func ValidateLogin(ctx context.Context, h *Handler, username string, password string) (*models.User, error)

Types

type Handler

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

func NewHandler

func NewHandler(db *mongo.Database) *Handler

func (*Handler) AddBankAccount

func (h *Handler) AddBankAccount(ctx context.Context, sellerID string, bankAccount models.BankAccount) (*mongo.UpdateResult, error)

func (*Handler) ChangeStatus

func (h *Handler) ChangeStatus(ctx context.Context, sellerID string, status string) (*mongo.UpdateResult, error)

func (*Handler) CheckPetStatus

func (h *Handler) CheckPetStatus(ctx context.Context, petID primitive.ObjectID) (bool, error)

Check pet status

func (*Handler) CreateComment

func (h *Handler) CreateComment(ctx context.Context, reviewID string, comment models.Comments) (*models.Review, error)

func (*Handler) CreateOTP

func (h *Handler) CreateOTP(ctx context.Context, otp, email string) error

func (*Handler) CreateOnePet

func (h *Handler) CreateOnePet(ctx context.Context, userID primitive.ObjectID, pet *models.Pet) error

CreateOnePet creates a new pet

func (*Handler) CreatePartyReport

func (h *Handler) CreatePartyReport(ctx context.Context, report *models.PartyReport) (*mongo.InsertOneResult, error)

func (*Handler) CreateReview

func (h *Handler) CreateReview(ctx context.Context, review *models.Review) (*mongo.InsertOneResult, error)

func (*Handler) CreateSystemReport

func (h *Handler) CreateSystemReport(ctx context.Context, report *models.SystemReport) (*mongo.InsertOneResult, error)

func (*Handler) CreateTransaction

func (h *Handler) CreateTransaction(ctx context.Context, transaction *models.Transaction) (*mongo.InsertOneResult, error)

func (*Handler) DeleteBankAccount

func (h *Handler) DeleteBankAccount(sellerID string) (*mongo.UpdateResult, error)

func (*Handler) DeleteOTP

func (h *Handler) DeleteOTP(ctx context.Context, email string) error

func (*Handler) DeleteOnePet

func (h *Handler) DeleteOnePet(ctx context.Context, petID string) (*mongo.DeleteResult, error)

DeleteOnePet deletes a pet

func (*Handler) DeleteOneUser

func (h *Handler) DeleteOneUser(ctx context.Context, userID string, storage *storage.Handler) (*mongo.DeleteResult, error)

DeleteOneUser deletes a user

func (*Handler) DeleteReview

func (h *Handler) DeleteReview(ctx context.Context, reviewID, role string, userID primitive.ObjectID) (*bson.M, error)

func (*Handler) GetAllMasterData

func (h *Handler) GetAllMasterData(ctx context.Context) (*[]models.MasterData, error)

GetAllMasterData returns all master data

func (*Handler) GetAllSellers

func (h *Handler) GetAllSellers(ctx context.Context, status string) (*[]models.Seller, error)

func (*Handler) GetBankAccount

func (h *Handler) GetBankAccount(sellerID string) (*models.BankAccount, error)

func (*Handler) GetCategories

func (h *Handler) GetCategories(ctx context.Context) (*models.MasterDataCategory, error)

GetCategories returns list of categories

func (*Handler) GetFilteredPetCards

func (h *Handler) GetFilteredPetCards(ctx context.Context, categories, species, sex, behaviors []string, minAge, maxAge, minWeight, maxWeight, minPrice, maxPrice int) (*[]models.PetCard, error)

Get filtered petCard

func (*Handler) GetMasterDataByCategory

func (h *Handler) GetMasterDataByCategory(ctx context.Context, category string) (*models.MasterData, error)

GetMasterDataByCategory returns master data by Category

func (*Handler) GetOTPbyEmail

func (h *Handler) GetOTPbyEmail(ctx context.Context, email string) (*models.OTP, error)

func (*Handler) GetPetByPetID

func (h *Handler) GetPetByPetID(ctx context.Context, petID string) (*models.Pet, error)

GetPetByPetID returns a pet by petID

func (*Handler) GetPetBySeller

func (h *Handler) GetPetBySeller(ctx context.Context, userID string) (*[]models.Pet, error)

GetPetBySeller returns pets that belong to a seller

func (*Handler) GetReport

func (h *Handler) GetReport(ctx context.Context, category string, is_solved *bool) (*[]models.PartyReport, *[]models.SystemReport, error)

func (*Handler) GetReviewByReviewID

func (h *Handler) GetReviewByReviewID(ctx context.Context, reviewID string) (*models.Review, error)

func (*Handler) GetReviewByUserID

func (h *Handler) GetReviewByUserID(ctx context.Context, UserID string) (*[]models.Review, error)

func (*Handler) GetSellerBySellerID

func (h *Handler) GetSellerBySellerID(ctx context.Context, sellerID string) (*models.Seller, error)

func (*Handler) GetTransactionByID

func (h *Handler) GetTransactionByID(ctx context.Context, userID primitive.ObjectID, role string) ([]*models.TransactionWithDetails, error)

func (*Handler) GetTransactionByTransactionID

func (h *Handler) GetTransactionByTransactionID(ctx context.Context, transactionID string) (*models.Transaction, error)

func (*Handler) GetUserByMail

func (h *Handler) GetUserByMail(ctx context.Context, data bson.M) (*models.User, error)

func (*Handler) GetUserByUserID

func (h *Handler) GetUserByUserID(ctx context.Context, userID string) (*models.User, error)

GetUserByUserID returns a user by userID

func (*Handler) UpdateBuyer

func (h *Handler) UpdateBuyer(ctx context.Context, buyerID string, data bson.M) (*mongo.UpdateResult, error)

func (*Handler) UpdateOnePet

func (h *Handler) UpdateOnePet(ctx context.Context, petID string, data bson.M) (*mongo.SingleResult, error)

UpdateOnePet updates a pet

func (*Handler) UpdateOneUser

func (h *Handler) UpdateOneUser(ctx context.Context, userID string, data bson.M) (*mongo.SingleResult, error)

UpdateOneUser updates a user

func (*Handler) UpdatePetStatus

func (h *Handler) UpdatePetStatus(ctx context.Context, petID primitive.ObjectID, status bool) (*mongo.SingleResult, error)

Update pet status

func (*Handler) UpdateSeller

func (h *Handler) UpdateSeller(ctx context.Context, sellerID string, data bson.M) (*mongo.UpdateResult, error)

func (*Handler) UpdateTransaction

func (h *Handler) UpdateTransaction(ctx context.Context, transactionID primitive.ObjectID, update bson.D) (*mongo.SingleResult, error)

Jump to

Keyboard shortcuts

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