Documentation ¶
Index ¶
- Constants
- type User
- func SelectUsers(db *sql.DB, additionalClauses string, bindValues ...interface{}) (results []User, err error)
- func SelectUsersAll(db *sql.DB) ([]User, error)
- func SelectUsersRow(db *sql.DB, additionalClauses string, bindValues ...interface{}) (User, error)
- func SelectUsersTx(tx *sql.Tx, additionalClauses string, bindValues ...interface{}) ([]User, error)
- func (r *User) Delete(db *sql.DB) (rowCount int64, err error)
- func (r *User) DeleteTx(tx *sql.Tx) (rowCount int64, err error)
- func (r User) Insert(db *sql.DB) (newR User, err error)
- func (r User) InsertTx(tx *sql.Tx) (User, error)
- func (u *User) PostInsert(tx *sql.Tx, tableName string) error
- func (u *User) PreInsert(tx *sql.Tx, tableName string) error
- func (r User) Update(db *sql.DB) (newR User, err error)
- func (r User) UpdateTx(tx *sql.Tx) (User, error)
Constants ¶
const (
TableName = "users"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type User ¶
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 ¶
SelectUsersAll does a Select with no additional conditions/clauses.
func SelectUsersRow ¶
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 ¶
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) DeleteTx ¶
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) InsertTx ¶
InsertTx will insert on User, given a transaction. Invokes PreInsert and PostInsert hooks. Returns new User with ID, timestamps, etc updated.