Versions in this module Expand all Collapse all v0 v0.0.2 Jul 13, 2019 Changes in this version + var ErrNestedTransactionsNotAllowed = errors.New("sqlkit/db: nested transactions not allowed") + var ErrNotAQuery = errors.New("sqlkit/db: query was not issued") + var ErrStatementInvalid = errors.New("sqlkit/db: statement invalid") + func StdLogger(s SQL) + type DB interface + Begin func(context.Context) (TX, error) + Close func() error + Delete func() DeleteStmt + Exec func(context.Context, SQL) *Result + Insert func() InsertStmt + Query func(context.Context, SQL) *Result + Select func(cols ...string) SelectStmt + TX func(ctx context.Context, fn func(ctx context.Context) error) error + Update func(string) UpdateStmt + func New(opts ...Option) DB + func Open(driverName, dataSourceName string, opts ...Option) (DB, error) + type DeleteStmt struct + func Delete() DeleteStmt + func (q DeleteStmt) From(table string) DeleteStmt + func (q DeleteStmt) InnerJoin(table, on string) DeleteStmt + func (q DeleteStmt) Join(kind, table, on string, values ...interface{}) DeleteStmt + func (q DeleteStmt) LeftJoin(table, on string) DeleteStmt + func (q DeleteStmt) RightJoin(table, on string) DeleteStmt + func (q DeleteStmt) SQL() (string, []interface{}, error) + func (q DeleteStmt) Where(where string, values ...interface{}) DeleteStmt + type Dialect int + const Generic + const MySQL + const Postgres + type InsertStmt struct + func Insert() InsertStmt + func (i InsertStmt) Columns(cols ...string) InsertStmt + func (i InsertStmt) Into(table string) InsertStmt + func (i InsertStmt) Record(obj interface{}) InsertStmt + func (i InsertStmt) Row(cols []string, vals []interface{}) InsertStmt + func (i InsertStmt) SQL() (string, []interface{}, error) + func (i InsertStmt) Value(column string, value interface{}) InsertStmt + func (i InsertStmt) Values(vals ...interface{}) InsertStmt + type Option func(db *db) + func WithConn(conn *sql.DB) Option + func WithDialect(dialect Dialect) Option + func WithDisabledSavepoints(enc encoding.Encoder) Option + func WithEncoder(enc encoding.Encoder) Option + func WithLogger(logger func(SQL)) Option + type Result struct + LastID int64 + RowsAffected int64 + func (r *Result) Decode(val interface{}) (err error) + func (r *Result) Err() error + type SQL interface + SQL func() (string, []interface{}, error) + func Raw(sql string, args ...interface{}) SQL + type SelectStmt struct + func Select(cols ...string) SelectStmt + func (q SelectStmt) From(table string) SelectStmt + func (q SelectStmt) GroupBy(groupBy ...string) SelectStmt + func (q SelectStmt) InnerJoin(table, on string) SelectStmt + func (q SelectStmt) Join(kind, table, on string, values ...interface{}) SelectStmt + func (q SelectStmt) LeftJoin(table, on string) SelectStmt + func (q SelectStmt) Limit(limit int) SelectStmt + func (q SelectStmt) Offset(offset int) SelectStmt + func (q SelectStmt) OrderBy(orderBy ...string) SelectStmt + func (q SelectStmt) RightJoin(table, on string) SelectStmt + func (q SelectStmt) SQL() (string, []interface{}, error) + func (q SelectStmt) Select(cols ...string) SelectStmt + func (q SelectStmt) Where(where string, values ...interface{}) SelectStmt + type TX interface + Commit func() error + Rollback func() error + WithContext func(ctx context.Context) TX + type UpdateStmt struct + func Update(table string) UpdateStmt + func (i UpdateStmt) Columns(cols ...string) UpdateStmt + func (i UpdateStmt) Record(obj interface{}) UpdateStmt + func (i UpdateStmt) SQL() (string, []interface{}, error) + func (i UpdateStmt) Table(table string) UpdateStmt + func (i UpdateStmt) Value(name string, val interface{}) UpdateStmt + func (i UpdateStmt) Values(vals ...interface{}) UpdateStmt + func (i UpdateStmt) Where(where string, args ...interface{}) UpdateStmt