repositories

package
v0.0.0-...-4b14bc7 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MongoUserRepository

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

func NewUserMongoRepository

func NewUserMongoRepository() *MongoUserRepository

NewMongoRepository the initializate the conections with the mongo database. create the collections of the document for persistence it also, create some rules for the database and return a instance of MongoRepository

func (*MongoUserRepository) CloseClient

func (mr *MongoUserRepository) CloseClient()

CloseClient Close the conections with de database

func (*MongoUserRepository) CreateUser

func (mr *MongoUserRepository) CreateUser(newUser *models.User) (models.User, error)

CreateUser recive the newUser to be persisntace in de database return the newUser and error if it exist

func (*MongoUserRepository) DeleteUserById

func (mr *MongoUserRepository) DeleteUserById(id string) (*models.User, error)

DeleteUserById wll delete the user with de paramaeter id and return the deleted user of the database. it also return an error if it exist

func (*MongoUserRepository) GetAllUsers

func (mr *MongoUserRepository) GetAllUsers(page int, maxUsers int) ([]models.User, error)

GetAllUsers return all the active users in the database recieve the page and max users per page, it also return a error if it exist

func (*MongoUserRepository) GetTotalUsers

func (mr *MongoUserRepository) GetTotalUsers() (int, error)

GetTotalUsers it wiil return the number of total active users it also return a error if it exist

func (*MongoUserRepository) GetUserByEmailAndPass

func (mr *MongoUserRepository) GetUserByEmailAndPass(email string, password string) (*models.User, error)

GetUserByEmialAndPass will return a user in the database with this information the password must be encrypt if is needed. it return de user and error if exist

func (*MongoUserRepository) GetUserByID

func (mr *MongoUserRepository) GetUserByID(id string) (models.User, error)

GetUserById recieve de id to search in the database if it exist it will be return and an error if it exist

func (*MongoUserRepository) ReplaceUser

func (mr *MongoUserRepository) ReplaceUser(newUser *models.User, id string) (models.User, error)

ReplaceUser replace de user with id of the parameter, and the information of the model of newUser, it return the old User and an error if it exist

func (*MongoUserRepository) UpdateUserById

func (mr *MongoUserRepository) UpdateUserById(newUser *models.User, id string) (*models.User, error)

UpdateUserById would update the user with the parameter id, all the information must be prepare, and it will return the old user and an error if it exist

Jump to

Keyboard shortcuts

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