dao

package
v1.7.5 Latest Latest
Warning

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

Go to latest
Published: May 29, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MaxIDResponse

type MaxIDResponse struct {
	MaxID int64 `bson:"MaxID"`
	// contains filtered or unexported fields
}

MaxIDResponse for response on pipe. Used for extracting current max id

type MockUserDao

type MockUserDao struct {
	mock.Mock
}

MockUserDao for testing only

func (*MockUserDao) DeleteById

func (m *MockUserDao) DeleteById(id int64) error

func (*MockUserDao) Get

func (m *MockUserDao) Get(id int64) (*structs.User, error)

func (*MockUserDao) GetAll

func (m *MockUserDao) GetAll() (*[]structs.User, error)

func (*MockUserDao) GetByEmail

func (m *MockUserDao) GetByEmail(uname string) (*structs.User, error)

func (*MockUserDao) GetByUsername

func (m *MockUserDao) GetByUsername(uname string) (*structs.User, error)

func (*MockUserDao) GetRecoveryCode

func (m *MockUserDao) GetRecoveryCode(id int64) (string, error)

func (*MockUserDao) GetResettingCode

func (m *MockUserDao) GetResettingCode(id int64) (string, error)

func (*MockUserDao) ResetPassword

func (m *MockUserDao) ResetPassword(id int64, passwordHash string) error

func (*MockUserDao) Save

func (m *MockUserDao) Save(u *structs.User) int64

func (*MockUserDao) SetRecoveryCode

func (m *MockUserDao) SetRecoveryCode(id int64, code string) error

func (*MockUserDao) SetResettingCode

func (m *MockUserDao) SetResettingCode(id int64, code string) error

func (*MockUserDao) Update

func (m *MockUserDao) Update(u *structs.User) error

type MongoUserDao

type MongoUserDao struct {
	Client       *mongo.Client
	DatabaseName string
	Ctx          context.Context
}

MongoUserDao provides UserDao implementation via MongoDB

func NewMongoUserDao

func NewMongoUserDao(URL string, databaseName string) *MongoUserDao

NewMongoUserDao creates instance of MongoUserDao

func (*MongoUserDao) DeleteById

func (d *MongoUserDao) DeleteById(id int64) error

DeleteById deletes user by id

func (*MongoUserDao) Get

func (d *MongoUserDao) Get(id int64) (*s.User, error)

Get returns user by id

func (*MongoUserDao) GetAll

func (d *MongoUserDao) GetAll() (*[]s.User, error)

GetAll extracts all users

func (*MongoUserDao) GetByEmail

func (d *MongoUserDao) GetByEmail(email string) (*s.User, error)

GetByEmail returns nil when user is not found Returns error if data access error occured

func (*MongoUserDao) GetByUsername

func (d *MongoUserDao) GetByUsername(username string) (*s.User, error)

GetByUsername extracts user by username

func (*MongoUserDao) GetRecoveryCode

func (d *MongoUserDao) GetRecoveryCode(id int64) (string, error)

GetRecoveryCode extracts recovery code for user id

func (*MongoUserDao) GetResettingCode

func (d *MongoUserDao) GetResettingCode(id int64) (string, error)

GetResettingCode extracts resetting code for user id

func (*MongoUserDao) ResetPassword

func (d *MongoUserDao) ResetPassword(id int64, passwordHash string) error

ResetPassword updates password and removes resetting code

func (*MongoUserDao) Save

func (d *MongoUserDao) Save(u *s.User) int64

Save saves user in MongoDB. Implemented to retry insertion several times if another thread inserts document between calculation of new id and insertion into collection.

func (*MongoUserDao) SetRecoveryCode

func (d *MongoUserDao) SetRecoveryCode(id int64, code string) error

SetRecoveryCode sets password recovery code for user id

func (*MongoUserDao) SetResettingCode

func (d *MongoUserDao) SetResettingCode(id int64, code string) error

SetResettingCode sets resetting code and removes recovery one

func (*MongoUserDao) Update

func (d *MongoUserDao) Update(u *s.User) error

Update updates user if exists

type MysqlUserDao

type MysqlUserDao struct {
	Db           *xorm.Engine
	DatabaseName string
	Ctx          context.Context
}

MysqlUserDao provides UserDao implementation via MongoDB

func NewMysqlUserDao

func NewMysqlUserDao(driverUrl string, databaseName string) *MysqlUserDao

NewMysqlUserDao creates instance of MysqlUserDao

func (*MysqlUserDao) DeleteById

func (d *MysqlUserDao) DeleteById(id int64) error

DeleteById deletes user by id

func (*MysqlUserDao) Get

func (d *MysqlUserDao) Get(id int64) (*s.User, error)

Get returns user by id

func (*MysqlUserDao) GetAll

func (d *MysqlUserDao) GetAll() (*[]s.User, error)

GetAll extracts all users

func (*MysqlUserDao) GetByEmail

func (d *MysqlUserDao) GetByEmail(email string) (*s.User, error)

GetByEmail returns nil when user is not found Returns error if data access error occured

func (*MysqlUserDao) GetByUsername

func (d *MysqlUserDao) GetByUsername(username string) (*s.User, error)

GetByUsername extracts user by username

func (*MysqlUserDao) GetRecoveryCode

func (d *MysqlUserDao) GetRecoveryCode(id int64) (string, error)

GetRecoveryCode extracts recovery code for user id

func (*MysqlUserDao) GetResettingCode

func (d *MysqlUserDao) GetResettingCode(id int64) (string, error)

GetResettingCode extracts resetting code for user id

func (*MysqlUserDao) ResetPassword

func (d *MysqlUserDao) ResetPassword(id int64, passwordHash string) error

ResetPassword updates password and removes resetting code

func (*MysqlUserDao) Save

func (d *MysqlUserDao) Save(u *s.User) int64

Save saves user in SQLDb. Implemented to retry insertion several times if another thread inserts document between calculation of new id and insertion into collection.

func (*MysqlUserDao) SetRecoveryCode

func (d *MysqlUserDao) SetRecoveryCode(id int64, code string) error

SetRecoveryCode sets password recovery code for user id

func (*MysqlUserDao) SetResettingCode

func (d *MysqlUserDao) SetResettingCode(id int64, code string) error

SetResettingCode sets resetting code and removes recovery one

func (*MysqlUserDao) Update

func (d *MysqlUserDao) Update(u *s.User) error

Update updates user if exists

type UserDao

type UserDao interface {

	// Save Returns generated id (> 0) on success.
	// Returns -1 on internal failure.
	Save(*structs.User) int64

	// GetByUsername returns nil when user is not found
	// Returns error if data access error occured
	GetByUsername(string) (*structs.User, error)

	// GetByEmail returns nil when user is not found
	// Returns error if data access error occured
	GetByEmail(string) (*structs.User, error)

	// Get returns nil when user is not found
	// Returns error if data access error occured
	Get(int64) (*structs.User, error)

	// GetAll returns all users or empty list
	GetAll() (*[]structs.User, error)

	// Update updates user if exists
	Update(*structs.User) error

	// SetRecoveryCode sets password recovery code for user id
	SetRecoveryCode(int64, string) error

	// GetRecoveryCode extracts recovery code for user id
	GetRecoveryCode(int64) (string, error)

	// SetResettingCode sets resetting code and removes recovery one
	SetResettingCode(int64, string) error

	// GetResettingCode extracts resetting code for user id
	GetResettingCode(int64) (string, error)

	// ResetPassword updates password and removes resetting code
	ResetPassword(int64, string) error

	// DeleteById deletes user by id
	DeleteById(int64) error
}

UserDao provides interface to persisting operations

Jump to

Keyboard shortcuts

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