Documentation ¶
Index ¶
- Variables
- func DeleteStatement(tableName string, keyColumns []string) string
- func InTransaction(db *sql.DB, operation func(*sql.Tx) error) error
- func InsertReturningStatement(tableName string, columnNames []string, returningColumnName string) string
- func InsertStatement(tableName string, columnNames []string) string
- func Log(format string, v ...interface{})
- func PostDelete(tx *sql.Tx, item interface{}, tableName string) error
- func PostInsert(tx *sql.Tx, item interface{}, tableName string) error
- func PostModify(tx *sql.Tx, item interface{}, tableName string) error
- func PostUpdate(tx *sql.Tx, item interface{}, tableName string) error
- func PreDelete(tx *sql.Tx, item interface{}, tableName string) error
- func PreInsert(tx *sql.Tx, item interface{}, tableName string) error
- func PreModify(tx *sql.Tx, item interface{}, tableName string) error
- func PreUpdate(tx *sql.Tx, item interface{}, tableName string) error
- func SelectStatement(tableName string, columnNames []string, additionalClauses string) string
- func SetLogger(logger Logger)
- func UnsetLogger()
- func UpdateStatement(tableName string, keyColumns []string, valueColumns []string) string
- type BindStyle
- type Logger
- type PostDeleter
- type PostInserter
- type PostModifier
- type PostUpdater
- type PreDeleter
- type PreInserter
- type PreModifier
- type PreUpdater
Constants ¶
This section is empty.
Variables ¶
var ( NoRowsUpdated error MoreThanOneRowUpdated error MoreThanOneRowDeleted error )
Some standard errors that generated code may return.
Functions ¶
func DeleteStatement ¶
DeleteStatement returns "delete from tablename where ..."
func InTransaction ¶
InTransaction wraps an operation in BEGIN/COMMIT.
func InsertReturningStatement ¶
func InsertReturningStatement(tableName string, columnNames []string, returningColumnName string) string
InsertReturningStatement returns "insert into tablename (...) values (...) returning id"
func InsertStatement ¶
InsertStatement returns "insert into tablename (...) values (...)"
func Log ¶
func Log(format string, v ...interface{})
Log will write a line to the logger, IFF it has been set to a non-nil value.
func PostDelete ¶
PostDelete checks if the passed in item has a PostDelete method and invokes it.
func PostInsert ¶
PostInsert checks if the passed in item has a PostInsert method and invokes it.
func PostModify ¶
PostModify checks if the passed in item has a PostModify method and invokes it.
func PostUpdate ¶
PostUpdate checks if the passed in item has a PostUpdate method and invokes it.
func SelectStatement ¶
SelectStatement constructs a select statement for the given table and columns, with optional additional clauses (where, order by, etc.)
Types ¶
type BindStyle ¶
type BindStyle int
BindStyle is an enum of styles of bind vars.
Varieties for supported bind-variable markers.
func (BindStyle) Rebind ¶
Rebind will convert question marks to another bind-var style, e.g. "$1, $2, ..." or ":arg, :arg, ..." (This is pretty much stolen directly from github.com/jmoiron/sqlx.)
type Logger ¶
type Logger interface {
Printf(format string, v ...interface{})
}
Logger is a thing that can write to a log.
type PostDeleter ¶
PostDeleter offers a post-deletion operation.
type PostInserter ¶
PostInserter offers a post-insert operation.
type PostModifier ¶
PostModifier offers an operation to be executed after any insert/update/delete operation. Will be executed *before* PostInsert/PostUpdate/PostDelete, but *after* actual SQL insert/update/delete.
type PostUpdater ¶
PostUpdater offers a post-update operation.
type PreDeleter ¶
PreDeleter offers a pre-delete operation.
type PreInserter ¶
PreInserter offers a pre-insert operation which might return an error to indicate the operation should be aborted.
type PreModifier ¶
PreModifier offers an operation to be executed before any insert/update/delete operation. Will be executed *after* PreInsert/PreUpdate/PreDelete, but *before* actual SQL insert/update/delete.