Documentation ¶
Index ¶
- func Config()
- func Count(tx *Tx, table string, where interface{}) (count uint64, err error)
- func Fetch(tx *Tx, table string, cols []string, where interface{}, limit, offset uint64, ...) (err error)
- func Insert(tx *Tx, table string) sq.InsertBuilder
- func Migrate(a asset) (err error)
- func Ping() bool
- func QueryContext(ctx context.Context, txFunc func(*Tx) error) (err error)
- func Replace(tx *Tx, d DbInfo, o interface{}, where interface{}, update sq.UpdateBuilder, ...) (found bool, err error)
- func Transaction(txFunc func(*Tx) error) (err error)
- func TransactionContext(ctx context.Context, txFunc func(*Tx) error) (err error)
- func TransactionContinue(TxID string, txFunc func(*Tx, string) error) (err error)
- func Transactionx(txFunc func(*sqlx.Tx) error) (err error)
- func Update(tx *Tx, table string) sq.UpdateBuilder
- type DB
- func (db DB) NewTx(ctx context.Context, readonly bool) (tx *Tx, err error)
- func (db DB) QueryContext(ctx context.Context, txFunc func(*Tx) error) (err error)
- func (db DB) Transaction(fn func(*Tx) error) error
- func (db DB) TransactionContext(ctx context.Context, txFunc func(*Tx) error) (err error)
- func (db DB) TransactionContinue(TxID string, txFunc func(*Tx, string) error) (err error)
- func (db DB) Transactionx(txFunc func(*sqlx.Tx) error) (err error)
- type DbInfo
- func (d DbInfo) Col(column string) (s string, err error)
- func (d DbInfo) ColPanic(column string) string
- func (d DbInfo) GCol(column string) (s string, err error)
- func (d DbInfo) Index(column string) (idx int, ok bool)
- func (d DbInfo) SCol(column string) (s string, err error)
- func (d DbInfo) StructMap(o interface{}, cols []string) (fields []string, targets []interface{}, err error)
- type FetchMap
- type Tx
- func (tx *Tx) Count(table string, where interface{}) (count uint64, err error)
- func (tx *Tx) Delete(table string) sq.DeleteBuilder
- func (tx *Tx) Fetch(table string, cols []string, where interface{}, limit, offset uint64, ...) (err error)
- func (tx *Tx) Insert(table string) sq.InsertBuilder
- func (tx *Tx) Replace(d DbInfo, o interface{}, where interface{}, update sq.UpdateBuilder, ...) (found bool, err error)
- func (tx *Tx) Select(cols []string, table string) sq.SelectBuilder
- func (tx *Tx) Update(table string) sq.UpdateBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Count ¶
Count returns a row count for query
func Fetch ¶
func Fetch(tx *Tx, table string, cols []string, where interface{}, limit, offset uint64, order []string, fn FetchMap) (err error)
Fetch fetch rows and pass through supplied function
func QueryContext ¶
QueryContext starts a new database tranaction and executes the supplied func with context.
func Replace ¶
func Replace( tx *Tx, d DbInfo, o interface{}, where interface{}, update sq.UpdateBuilder, insert sq.InsertBuilder, ) (found bool, err error)
Replace begin new replace statement.
func Transaction ¶
Transaction starts a new database tranaction and executes the supplied func.
func TransactionContext ¶
TransactionContext starts a new database tranaction and executes the supplied func with context.
func TransactionContinue ¶
TransactionContinue returns a transaction that can be continued by suppling the TxID that gets passed into the txFunc.
func Transactionx ¶
Transactionx starts a new database tranaction and executes the supplied func.
Types ¶
type DB ¶
type DB struct { Conn *sql.DB DbType string Placeholder sq.PlaceholderFormat Returns bool TxOptionsDisable bool }
DB database connection and settings
func (DB) NewTx ¶
NewTx create new transaction
func (DB) QueryContext ¶
QueryContext starts a new database transction with context and executes the supplied func.
func (DB) Transaction ¶
Transaction starts a new database transction and executes the supplied func.
func (DB) TransactionContext ¶
TransactionContext starts a new database transction with context and executes the supplied func.
func (DB) TransactionContinue ¶
TransactionContinue returns a transaction that can be continued by suppling the TxID that gets passed into the txFunc.
type DbInfo ¶
type DbInfo struct { Table string View string Cols []string SCols []string GCols []string Auto []string // contains filtered or unexported fields }
DbInfo database model metadata
func (DbInfo) Col ¶
Col returns the mapped column names
func (DbInfo) ColPanic ¶
ColPanic returns the mapped column names will panic if col does not exist
func (DbInfo) GCol ¶
GCol returns the graphql column names
func (DbInfo) Index ¶
Index returns the column number
func (DbInfo) SCol ¶
SCol returns the struct column names
type FetchMap ¶
FetchMap is passed to fetch for assigning to objects.
type Tx ¶
type Tx struct { *sql.Tx context.Context DbType string Placeholder sq.PlaceholderFormat Returns bool }
Tx database transaction
func (*Tx) Count ¶
Count returns a row count for query
func (*Tx) Delete ¶
func (tx *Tx) Delete(table string) sq.DeleteBuilder
Delete begin new delete statement.
func (*Tx) Fetch ¶
func (tx *Tx) Fetch(table string, cols []string, where interface{}, limit, offset uint64, order []string, fn FetchMap) (err error)
Fetch fetch rows and pass through supplied function
func (*Tx) Insert ¶
func (tx *Tx) Insert(table string) sq.InsertBuilder
Insert begin new insert statement.
func (*Tx) Replace ¶
func (tx *Tx) Replace( d DbInfo, o interface{}, where interface{}, update sq.UpdateBuilder, insert sq.InsertBuilder, ) (found bool, err error)
Replace begin new replace statement.
func (*Tx) Select ¶
func (tx *Tx) Select(cols []string, table string) sq.SelectBuilder
Select begin new select statement.
func (*Tx) Update ¶
func (tx *Tx) Update(table string) sq.UpdateBuilder
Update begin new update statement.