Documentation ¶
Index ¶
- Constants
- func RowsToUser(rows *sql.Rows, containsPagination bool) []models.User
- type UserMongoRepository
- func (ur *UserMongoRepository) CommitTransaction()
- func (ur *UserMongoRepository) CreateUser(user models.User) error
- func (ur *UserMongoRepository) FindUsersByUsernameOrEmail(q string, page int) []models.User
- func (ur *UserMongoRepository) GetUserByUsername(username string) []models.User
- func (ur *UserMongoRepository) InitUsers()
- func (ur *UserMongoRepository) OpenTransaction() error
- func (ur *UserMongoRepository) Release()
- func (ur *UserMongoRepository) RollbackTransaction()
- func (ur *UserMongoRepository) UpdateUser(user models.User) error
- type UserOracleRepository
- func (agmr *UserOracleRepository) CommitTransaction()
- func (ur *UserOracleRepository) CreateUser(user models.User) error
- func (ur *UserOracleRepository) FindUsersByUsernameOrEmail(q string, page int) []models.User
- func (ur *UserOracleRepository) GetUserByUsername(username string) []models.User
- func (agmr *UserOracleRepository) InitUsers()
- func (agmr *UserOracleRepository) OpenTransaction() error
- func (agmr *UserOracleRepository) Release()
- func (agmr *UserOracleRepository) RollbackTransaction()
- func (ur *UserOracleRepository) UpdateUser(user models.User) error
- type UserRepository
Constants ¶
const ( FIND_BY_EMAIL_OR_USERNAME = `select id, username, password, email, isadmin from gapi_users where email like :email or username like :username` FIND_BY_USERNAME = `select id, username, password, email, isadmin from gapi_users where username = :username` UPDATE_USER_ORACLE = `` /* 130-byte string literal not displayed */ INSERT_USER_ORACLE = `insert into gapi_users (id, username, password, email, isadmin) values (:id, :username, :password, :email, :isadmin)` )
const (
PAGE_LENGTH = 10
)
const (
USERS_COLLECTION = "users"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type UserMongoRepository ¶
type UserMongoRepository struct { Session *mgo.Session Db *mgo.Database Collection *mgo.Collection }
func (*UserMongoRepository) CommitTransaction ¶
func (ur *UserMongoRepository) CommitTransaction()
CommitTransaction commits a database transaction
func (*UserMongoRepository) CreateUser ¶
func (ur *UserMongoRepository) CreateUser(user models.User) error
CreateUser create a new user
func (*UserMongoRepository) FindUsersByUsernameOrEmail ¶
func (ur *UserMongoRepository) FindUsersByUsernameOrEmail(q string, page int) []models.User
FindUsersByUsernameOrEmail return a list of users searched by username or email
func (*UserMongoRepository) GetUserByUsername ¶
func (ur *UserMongoRepository) GetUserByUsername(username string) []models.User
GetUserByUsername return a list of users search by username
func (*UserMongoRepository) InitUsers ¶
func (ur *UserMongoRepository) InitUsers()
InitUsers inits user required modules
func (*UserMongoRepository) OpenTransaction ¶
func (ur *UserMongoRepository) OpenTransaction() error
OpenTransaction opens a new database transaction
func (*UserMongoRepository) Release ¶
func (ur *UserMongoRepository) Release()
Release releases a database connection to the pool
func (*UserMongoRepository) RollbackTransaction ¶
func (ur *UserMongoRepository) RollbackTransaction()
RollbackTransaction rollbacks a database transaction
func (*UserMongoRepository) UpdateUser ¶
func (ur *UserMongoRepository) UpdateUser(user models.User) error
UpdateUser update an existing user
type UserOracleRepository ¶
func (*UserOracleRepository) CommitTransaction ¶
func (agmr *UserOracleRepository) CommitTransaction()
CommitTransaction commits a database transaction
func (*UserOracleRepository) CreateUser ¶
func (ur *UserOracleRepository) CreateUser(user models.User) error
CreateUser create a new user
func (*UserOracleRepository) FindUsersByUsernameOrEmail ¶
func (ur *UserOracleRepository) FindUsersByUsernameOrEmail(q string, page int) []models.User
FindUsersByUsernameOrEmail return a list of users searched by username or email
func (*UserOracleRepository) GetUserByUsername ¶
func (ur *UserOracleRepository) GetUserByUsername(username string) []models.User
GetUserByUsername return a list of users search by username
func (*UserOracleRepository) InitUsers ¶
func (agmr *UserOracleRepository) InitUsers()
InitUsers inits user required modules
func (*UserOracleRepository) OpenTransaction ¶
func (agmr *UserOracleRepository) OpenTransaction() error
OpenTransaction opens a new database transaction
func (*UserOracleRepository) Release ¶
func (agmr *UserOracleRepository) Release()
Release releases a database connection to the pool
func (*UserOracleRepository) RollbackTransaction ¶
func (agmr *UserOracleRepository) RollbackTransaction()
RollbackTransaction rollbacks a database transaction
func (*UserOracleRepository) UpdateUser ¶
func (ur *UserOracleRepository) UpdateUser(user models.User) error
UpdateUser update an existing user
type UserRepository ¶
type UserRepository interface { InitUsers() CreateUser(user models.User) error UpdateUser(user models.User) error FindUsersByUsernameOrEmail(q string, page int) []models.User GetUserByUsername(username string) []models.User OpenTransaction() error CommitTransaction() RollbackTransaction() Release() }
func NewUserRepository ¶
func NewUserRepository(user models.User) UserRepository
NewUserRepository create an user repository based on the database