providers

package
v0.0.0-...-9b02830 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
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)`
)
View Source
const (
	PAGE_LENGTH = 10
)
View Source
const (
	USERS_COLLECTION = "users"
)

Variables

This section is empty.

Functions

func RowsToUser

func RowsToUser(rows *sql.Rows, containsPagination bool) []models.User

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

type UserOracleRepository struct {
	Db      *sql.DB
	DbError error
	Tx      *sql.Tx
}

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

Jump to

Keyboard shortcuts

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