Documentation ¶
Index ¶
- Constants
- func InitMongoDB(logger *logrus.Logger) *mongo.Database
- func TimeOutContext() (context.Context, context.CancelFunc)
- func TimeOutContextWithParent(parent context.Context) (context.Context, context.CancelFunc)
- type MongoRepository
- type Repository
- type UserAuthRepo
- func (r *UserAuthRepo) Create(c context.Context, t *model.UserAuth) (model.UserAuth, error)
- func (r *UserAuthRepo) CreateToken(c context.Context, t *model.UserToken) (model.UserToken, error)
- func (r *UserAuthRepo) DeleteTokenByUserAndDevice(c context.Context, uname, dvcid string) (bool, error)
- func (r *UserAuthRepo) FindByEmail(c context.Context, email string) (model.UserAuth, error)
- func (r *UserAuthRepo) FindByID(c context.Context, id string) (model.UserAuth, error)
- func (r *UserAuthRepo) FindByPhone(c context.Context, mobile string) (model.UserAuth, error)
- func (r *UserAuthRepo) FindByUsername(c context.Context, uname string) (model.UserAuth, error)
- func (r *UserAuthRepo) FindTokenByUserAndDevice(c context.Context, uname, dvcid string) (model.UserToken, error)
- type UserRepository
Constants ¶
const ( ErrMgoInvalidOID = "invalid ObjectId: %s" ErrMgoOpsFail = "fail MongoOperation : %s" )
Err
Variables ¶
This section is empty.
Functions ¶
func TimeOutContext ¶
func TimeOutContext() (context.Context, context.CancelFunc)
TimeOutContext is a global context for mongodb connection access
func TimeOutContextWithParent ¶
TimeOutContextWithParent is a global context for mongodb connection access with parent Context
Types ¶
type MongoRepository ¶
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) CreateToken ¶
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 ¶
FindByEmail is finding UserAuth by its Email
func (*UserAuthRepo) FindByPhone ¶
FindByMobile is finding UserAuth by its Mobile
func (*UserAuthRepo) FindByUsername ¶
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 ...