repository

package
v0.0.0-...-8176360 Latest Latest
Warning

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

Go to latest
Published: May 20, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrMgoInvalidOID = "invalid ObjectId: %s"
	ErrMgoOpsFail    = "fail MongoOperation : %s"
)

Err

Variables

This section is empty.

Functions

func InitMongoDB

func InitMongoDB(logger *logrus.Logger) *mongo.Database

func TimeOutContext

func TimeOutContext() (context.Context, context.CancelFunc)

TimeOutContext is a global context for mongodb connection access

func TimeOutContextWithParent

func TimeOutContextWithParent(parent context.Context) (context.Context, context.CancelFunc)

TimeOutContextWithParent is a global context for mongodb connection access with parent Context

Types

type MongoRepository

type MongoRepository struct {
	DB *mongo.Database
	// contains filtered or unexported fields
}

MongoRepository implementation of `service.Repository`

func BuildMongoRepository

func BuildMongoRepository(db *mongo.Database) *MongoRepository

func (*MongoRepository) UserRepository

func (m *MongoRepository) UserRepository() UserRepository

type Repository

type Repository interface {
	UserRepository() UserRepository
}

Repository is base interface for any kind of Repository

type UserAuthRepo

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

UserAuthRepo repository

func NewUserAuthRepo

func NewUserAuthRepo(db *mongo.Database, log *logrus.Logger) *UserAuthRepo

NewUserAuthRepo is new instantiation of UserAuthRepo

func (*UserAuthRepo) Create

Create new UserAuth

func (*UserAuthRepo) CreateToken

func (r *UserAuthRepo) CreateToken(c context.Context, t *model.UserToken) (model.UserToken, error)

CreateToken new UserToken for UserAuth

func (*UserAuthRepo) DeleteTokenByUserAndDevice

func (r *UserAuthRepo) DeleteTokenByUserAndDevice(c context.Context, uname, dvcid string) (bool, error)

DeleteTokenByUserAndDevice is removing UserToken by Username & DeviceID

func (*UserAuthRepo) FindByEmail

func (r *UserAuthRepo) FindByEmail(c context.Context, email string) (model.UserAuth, error)

FindByEmail is finding UserAuth by its Email

func (*UserAuthRepo) FindByID

func (r *UserAuthRepo) FindByID(c context.Context, id string) (model.UserAuth, error)

FindByID is finding UserAuth by its ID

func (*UserAuthRepo) FindByPhone

func (r *UserAuthRepo) FindByPhone(c context.Context, mobile string) (model.UserAuth, error)

FindByMobile is finding UserAuth by its Mobile

func (*UserAuthRepo) FindByUsername

func (r *UserAuthRepo) FindByUsername(c context.Context, uname string) (model.UserAuth, error)

FindByUsername is finding UserAuth by its Username

func (*UserAuthRepo) FindTokenByUserAndDevice

func (r *UserAuthRepo) FindTokenByUserAndDevice(c context.Context, uname, dvcid string) (model.UserToken, error)

FindTokenByUserAndDevice is finding UserToken by Username & DeviceID which not expired yet

type UserRepository

type UserRepository interface {
	Create(c context.Context, t *model.UserAuth) (model.UserAuth, error)
	CreateToken(c context.Context, t *model.UserToken) (model.UserToken, error)
	DeleteTokenByUserAndDevice(c context.Context, uname, dvcid string) (bool, error)
	FindTokenByUserAndDevice(c context.Context, uname, dvcid string) (model.UserToken, error)
	FindByPhone(c context.Context, mobile string) (model.UserAuth, error)
	FindByEmail(c context.Context, email string) (model.UserAuth, error)
	FindByUsername(c context.Context, uname string) (model.UserAuth, error)
	FindByID(c context.Context, id string) (model.UserAuth, error)
}

UserRepository ...

Jump to

Keyboard shortcuts

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