Documentation ¶
Index ¶
- Constants
- func IsDup(err error) bool
- type MongoUserDB
- func (db *MongoUserDB) CreateUser(user *models.User) error
- func (db *MongoUserDB) DeleteUser(user *models.User) error
- func (db *MongoUserDB) FindByEmail(email string) (*models.User, error)
- func (db *MongoUserDB) FindById(id string) (*models.User, error)
- func (db *MongoUserDB) FindByUsername(username string) (*models.User, error)
- func (db *MongoUserDB) GetCache(id string) (*models.User, bool, error)
- func (db *MongoUserDB) SetCache(user *models.User) error
- func (db *MongoUserDB) UpdateUser(user *models.User) error
- type OnlineStatus
- type OnlineStatusDB
- type RedisStatusDatabase
- type UserDB
Constants ¶
View Source
const Offline = 0
View Source
const Online = 1
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MongoUserDB ¶
type MongoUserDB struct {
// contains filtered or unexported fields
}
func NewUserDatabase ¶
func NewUserDatabase(logger *zap.SugaredLogger, userCache *cache.Cache) *MongoUserDB
func (*MongoUserDB) CreateUser ¶
func (db *MongoUserDB) CreateUser(user *models.User) error
func (*MongoUserDB) DeleteUser ¶
func (db *MongoUserDB) DeleteUser(user *models.User) error
func (*MongoUserDB) FindByEmail ¶
func (db *MongoUserDB) FindByEmail(email string) (*models.User, error)
FindByEmail returns the user, if found, with the given email. This is NOT cached
func (*MongoUserDB) FindById ¶
func (db *MongoUserDB) FindById(id string) (*models.User, error)
FindById returns the user, if found, with the given id. This is cached
func (*MongoUserDB) FindByUsername ¶
func (db *MongoUserDB) FindByUsername(username string) (*models.User, error)
FindByUsername returns the user, if found, with the given username. This is NOT cached
func (*MongoUserDB) UpdateUser ¶
func (db *MongoUserDB) UpdateUser(user *models.User) error
type OnlineStatus ¶
type OnlineStatusDB ¶
type OnlineStatusDB interface { //SetOnlineStatus sets the online status of the user SetOnlineStatus(id string, status *OnlineStatus) error //GetOnlineStatus returns the online status of the user GetOnlineStatus(id string) (*OnlineStatus, error) }
type RedisStatusDatabase ¶
type RedisStatusDatabase struct {
// contains filtered or unexported fields
}
func NewOnlineStatusDatabase ¶
func NewOnlineStatusDatabase(logger *zap.SugaredLogger, client *redis.Client) *RedisStatusDatabase
func (*RedisStatusDatabase) GetOnlineStatus ¶
func (db *RedisStatusDatabase) GetOnlineStatus(id string) (*OnlineStatus, error)
func (*RedisStatusDatabase) SetOnlineStatus ¶
func (db *RedisStatusDatabase) SetOnlineStatus(id string, status *OnlineStatus) error
type UserDB ¶
type UserDB interface { //CreateUser saves the new user to the database. If a user with the same id exists already, a error will be returned. CreateUser(user *models.User) error //UpdateUser updates the existing user. UpdateUser(user *models.User) error //DeleteUser deletes the user from the database. DeleteUser(user *models.User) error //FindById returns the user, if found, with the given id. This is Cached FindById(id string) (*models.User, error) //FindByEmail returns the user, if found, with the given email. This is NOT Cached FindByEmail(email string) (*models.User, error) //FindByUsername returns the user, if found, with the given username. This is NOT Cached FindByUsername(username string) (*models.User, error) }
UserDB is the interface for the user database.
Click to show internal directories.
Click to hide internal directories.