Documentation ¶
Index ¶
- Variables
- func Now() time.Time
- type Context
- type DB
- func (d *DB) Exec(query string, args ...interface{}) (sql.Result, error)
- func (d *DB) Migrate(rc string) (upgrade.Results, error)
- func (d *DB) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (d *DB) QueryRow(query string, args ...interface{}) *sql.Row
- func (d *DB) QueryRowx(query string, args ...interface{}) *sqlx.Row
- func (d *DB) Queryx(query string, args ...interface{}) (*sqlx.Rows, error)
- func (d *DB) Transaction(h TransactionHandler) error
- func (d *DB) Wrap(cxt Context) Context
- type Option
- type TransactionHandler
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotFound = errors.New("Not found") ErrImmutable = errors.New("Immutable") ErrInvalidField = errors.New("Invalid field") ErrInvalidKeyCount = errors.New("Invalid primary key count") ErrNotAPointer = errors.New("Not a pointer") ErrNotAStruct = errors.New("Not a struct") ErrMissingField = errors.New("Missing field") )
Functions ¶
Types ¶
type Context ¶
type Context interface { Exec(query string, args ...interface{}) (sql.Result, error) Query(query string, args ...interface{}) (*sql.Rows, error) QueryRow(query string, args ...interface{}) *sql.Row Queryx(query string, args ...interface{}) (*sqlx.Rows, error) QueryRowx(query string, args ...interface{}) *sqlx.Row }
An SQL context. This defines a unified type that encompasses the basic methods of sql.DB and sql.Tx so they can be used interchangably.
type DB ¶
func (*DB) Transaction ¶
func (d *DB) Transaction(h TransactionHandler) error
Execute in a transaction. A transaction is created and the handler is invoked. If the handler returns a non-nil error the transaction is rolled back, otherwise the transaction is committed.
type TransactionHandler ¶
Click to show internal directories.
Click to hide internal directories.