Documentation
¶
Overview ¶
Package gopherbouncepostgres provides Postgres bindings for the gopherbounce package.
Index ¶
- Constants
- Variables
- func DefaultPostgreReplacer() *gopherbouncedb.SQLTemplateReplacer
- type PGBridge
- type PGQueries
- func (q *PGQueries) DeleteUser() string
- func (q *PGQueries) GetUser() string
- func (q *PGQueries) GetUserByEmail() string
- func (q *PGQueries) GetUserByName() string
- func (q *PGQueries) InitUsers() []string
- func (q *PGQueries) InsertUser() string
- func (q *PGQueries) ListUsers() string
- func (q *PGQueries) SupportsUserFields() bool
- func (q *PGQueries) UpdateUser(fields []string) string
- type PGSessionQueries
- func (q *PGSessionQueries) CleanUpSession() string
- func (q *PGSessionQueries) DeleteForUserSession() string
- func (q *PGSessionQueries) DeleteSession() string
- func (q *PGSessionQueries) GetSession() string
- func (q *PGSessionQueries) InitSessions() []string
- func (q *PGSessionQueries) InsertSession() string
- type PGSessionStorage
- type PGStorage
- type PGUserStorage
Constants ¶
const ( PGUsersInit = `` /* 396-byte string literal not displayed */ PGUsernameIndex = `CREATE INDEX IF NOT EXISTS idx_users_username ON $USERS_TABLE_NAME$(username);` PGEMailIndex = `CREATE INDEX IF NOT EXISTS idx_users_email ON $USERS_TABLE_NAME$(email);` PGQueryUserID = `SELECT * FROM $USERS_TABLE_NAME$ WHERE id=$1;` PGQueryUsername = `SELECT * FROM $USERS_TABLE_NAME$ WHERE username=$1;` PQQueryEmail = `SELECT * FROM $USERS_TABLE_NAME$ WHERE email=$1;` PGInsertUser = `` /* 203-byte string literal not displayed */ PGUpdateUser = `` /* 184-byte string literal not displayed */ PGDeleteUser = `DELETE FROM $USERS_TABLE_NAME$ WHERE id=$1;` PGListUsers = `SELECT * FROM $USERS_TABLE_NAME$;` PGUpdateUserFields = `UPDATE $USERS_TABLE_NAME$ SET $UPDATE_CONTENT$ WHERE id=$ID_PARAM_NUM$;` PGSessionsInit = `` /* 195-byte string literal not displayed */ PGInsertSession = `INSERT INTO $SESSIONS_TABLE_NAME$( session_key, user_, expire_date) VALUES($1, $2, $3);` PGGetSession = `SELECT * FROM $SESSIONS_TABLE_NAME$ WHERE session_key=$1;` PGDeleteSession = `DELETE FROM $SESSIONS_TABLE_NAME$ WHERE session_key=$1;` PGCleanUpSession = `DELETE FROM $SESSIONS_TABLE_NAME$ WHERE expire_date < $1;` PGDeleteSessionForUser = `DELETE FROM $SESSIONS_TABLE_NAME$ WHERE user_=$1;` )
const ( // PGKeyExists is the error code from the pq driver that states // that a key error occurred. PGKeyExists = "23505" )
Variables ¶
var (
DefaultPGRowNames = gopherbouncedb.DefaultUserRowNames
)
Functions ¶
func DefaultPostgreReplacer ¶
func DefaultPostgreReplacer() *gopherbouncedb.SQLTemplateReplacer
Types ¶
type PGBridge ¶
type PGBridge struct{}
func NewPGBridge ¶
func NewPGBridge() PGBridge
func (PGBridge) ConvertTime ¶
func (PGBridge) ConvertTimeScanType ¶
func (PGBridge) IsDuplicateInsert ¶
func (PGBridge) IsDuplicateUpdate ¶
func (PGBridge) TimeScanType ¶
func (b PGBridge) TimeScanType() interface{}
type PGQueries ¶
type PGQueries struct { InitS []string GetUserS, GetUserByNameS, GetUserByEmailS, InsertUserS, UpdateUserS, DeleteUserS, UpdateFieldsS, ListUsersS string Replacer *gopherbouncedb.SQLTemplateReplacer RowNames map[string]string }
PGQueries implements gopherbouncedb.UserSQL with support for Postgres.
func NewPGQueries ¶
func (*PGQueries) DeleteUser ¶
func (*PGQueries) GetUserByEmail ¶
func (*PGQueries) GetUserByName ¶
func (*PGQueries) InsertUser ¶
func (*PGQueries) SupportsUserFields ¶
func (*PGQueries) UpdateUser ¶
type PGSessionQueries ¶
type PGSessionQueries struct { InitS []string InsertSessionS, GetSessionS, DeleteSessionS, CleanUpSessionS, DeleteForUserSessionS string Replacer *gopherbouncedb.SQLTemplateReplacer }
PGSessionQueries implements gopherbouncedb.SessionSQL with support for Postgres.
func NewPGSessionQueries ¶
func NewPGSessionQueries(replaceMapping map[string]string) *PGSessionQueries
NewPGSessionQueries returns new queries given the replacement mapping that is used to update the default replacer.
That is it uses the default Postgres replacer, but updates the fields given in replaceMapping to overwrite existing values / insert new ones.
func (*PGSessionQueries) CleanUpSession ¶
func (q *PGSessionQueries) CleanUpSession() string
func (*PGSessionQueries) DeleteForUserSession ¶
func (q *PGSessionQueries) DeleteForUserSession() string
func (*PGSessionQueries) DeleteSession ¶
func (q *PGSessionQueries) DeleteSession() string
func (*PGSessionQueries) GetSession ¶
func (q *PGSessionQueries) GetSession() string
func (*PGSessionQueries) InitSessions ¶
func (q *PGSessionQueries) InitSessions() []string
func (*PGSessionQueries) InsertSession ¶
func (q *PGSessionQueries) InsertSession() string
type PGSessionStorage ¶
type PGSessionStorage struct {
*gopherbouncedb.SQLSessionStorage
}
PGSessionStorage is as session storage based on Postgres.
func NewPGSessionStorage ¶
func NewPGSessionStorage(db *sql.DB, replaceMapping map[string]string) *PGSessionStorage
NewPGSessionStorage creates a new Postgres session storage given the database connection and the replacement mapping used to create the queries with NewPGSessionQueries.
If you want to configure any options please read the gopherbounce wiki.
type PGStorage ¶
type PGStorage struct { *PGUserStorage *PGSessionStorage }
PGStorage combines a user storage and a session storage (both based on Postgres) to implement gopherbouncedb.Storage.
type PGUserStorage ¶
type PGUserStorage struct {
*gopherbouncedb.SQLUserStorage
}
func NewPGUserStorage ¶
func NewPGUserStorage(db *sql.DB, replaceMapping map[string]string) *PGUserStorage
func (*PGUserStorage) InsertUser ¶
func (s *PGUserStorage) InsertUser(user *gopherbouncedb.UserModel) (gopherbouncedb.UserID, error)
overwrites because of returning, must use query row