repository

package
v0.0.0-...-37207e6 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IUserRepository

type IUserRepository interface {
	AddUser(context.Context, UserEntity) (string, error)
	GetUser(context.Context, string) (UserDocument, error)
	UpdateUser(context.Context, string, UserEntity) error
	DeleteUser(context.Context, string) error
}

IUserRepository defines user operations

type MongoUserRepository

type MongoUserRepository struct {
	DB *mongo.Database
}

MongoUserRepository gives mongo implementation for user operations

func (*MongoUserRepository) AddUser

func (usr *MongoUserRepository) AddUser(ctx context.Context, user UserEntity) (string, error)

AddUser adds new user to the database

func (*MongoUserRepository) DeleteUser

func (usr *MongoUserRepository) DeleteUser(ctx context.Context, id string) error

DeleteUser deletes user document for given id

func (*MongoUserRepository) GetUser

func (usr *MongoUserRepository) GetUser(ctx context.Context, id string) (UserDocument, error)

GetUser fetches user info from the database

func (*MongoUserRepository) UpdateUser

func (usr *MongoUserRepository) UpdateUser(ctx context.Context, id string, user UserEntity) error

UpdateUser updates user data in the database

type UserDocument

type UserDocument struct {
	FirstName string `json:"firstname" bson:"firstname"`
	LastName  string `json:"lastname" bson:"lastname"`
	Email     string `json:"email" bson:"email"`
	Phone     string `json:"phone" bson:"phone"`
	Country   string `json:"country" bson:"country"`
}

UserDocument is user object for mongo document retrieval

type UserEntity

type UserEntity struct {
	FirstName string `json:"firstname" bson:"firstname"`
	LastName  string `json:"lastname" bson:"lastname"`
	Email     string `json:"email" bson:"email"`
	Phone     string `json:"phone" bson:"phone"`
	Country   string `json:"country" bson:"country"`
}

UserEntity is user object for document

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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