user

package
v0.0.0-...-7392356 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TableName = "users"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type User

type User struct {
	V     version.Version
	Name  string
	Email string
	Phone string
}

User is a human who visits our site.

func SelectUsers

func SelectUsers(db *sql.DB, additionalClauses string, bindValues ...interface{}) (results []User, err error)

SelectUsers wraps SelectUsersTx in a transaction.

func SelectUsersAll

func SelectUsersAll(db *sql.DB) ([]User, error)

SelectUsersAll does a Select with no additional conditions/clauses.

func SelectUsersRow

func SelectUsersRow(db *sql.DB, additionalClauses string, bindValues ...interface{}) (User, error)

SelectUsersRow will select one record from table users and return a User. The additionalClauses argument should be SQL to be appended to the "select ... from users" statement, using "?" for bind variables. E.g. "where foo = ?". bindValues must be provided in the correct order to match bind placeholders in the additionalClauses. Returns sql.ErrNoRows if no rows found.

func SelectUsersTx

func SelectUsersTx(tx *sql.Tx, additionalClauses string, bindValues ...interface{}) ([]User, error)

SelectUsersTx will select records from table users and return a slice of User. The additionalClauses argument should be SQL to be appended to the "select ... from users" statement, using "?" for bind variables. E.g. "where foo = ?". bindValues must be provided in the correct order to match bind placeholders in the additionalClauses.

func (*User) Delete

func (r *User) Delete(db *sql.DB) (rowCount int64, err error)

Wraps DeleteTx() in a transaction.

func (*User) DeleteTx

func (r *User) DeleteTx(tx *sql.Tx) (rowCount int64, err error)

DeleteTx executes PreDelete, delete, and PostDelete within a transaction. Will fail if delete affects more than one row. No error if 0 rows are deleted.

func (User) Insert

func (r User) Insert(db *sql.DB) (newR User, err error)

Insert wraps InsertTx() in a transaction.

func (User) InsertTx

func (r User) InsertTx(tx *sql.Tx) (User, error)

InsertTx will insert on User, given a transaction. Invokes PreInsert and PostInsert hooks. Returns new User with ID, timestamps, etc updated.

func (*User) PostInsert

func (u *User) PostInsert(tx *sql.Tx, tableName string) error

func (*User) PreInsert

func (u *User) PreInsert(tx *sql.Tx, tableName string) error

func (User) Update

func (r User) Update(db *sql.DB) (newR User, err error)

Wraps UpdateTx() in a transaction.

func (User) UpdateTx

func (r User) UpdateTx(tx *sql.Tx) (User, error)

UpdateTx will update a row, given a transaction. Will fail and return an error if not exactly 1 row is updated. Returns new User with timestamps, etc updated.

Jump to

Keyboard shortcuts

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