Versions in this module Expand all Collapse all v1 v1.0.4 Apr 7, 2022 Changes in this version + const FullJoin + const InnerJoin + const InnerLateralJoin + const LeftJoin + const LeftLateralJoin + const RightJoin + const RightLateralJoin + type AndOrCondition struct + Conditions []WhereCondition + Or bool + func And(conds ...WhereCondition) AndOrCondition + func Or(conds ...WhereCondition) AndOrCondition + func (andOr AndOrCondition) Parse() (asSQL string, bindings []interface{}) + type ArrayCondition struct + Left interface{} + Operator string + Right interface{} + Type string + func Any(arr interface{}, value interface{}) ArrayCondition + func EqAll(arr interface{}, value interface{}) ArrayCondition + func EqAny(arr interface{}, value interface{}) ArrayCondition + func GtAll(arr interface{}, value interface{}) ArrayCondition + func GtAny(arr interface{}, value interface{}) ArrayCondition + func GteAll(arr interface{}, value interface{}) ArrayCondition + func GteAny(arr interface{}, value interface{}) ArrayCondition + func ILikeAny(arr interface{}, value interface{}) ArrayCondition + func ILikeIn(arr interface{}, value interface{}) ArrayCondition + func LikeAny(arr interface{}, value interface{}) ArrayCondition + func LikeIn(arr interface{}, value interface{}) ArrayCondition + func LtAll(arr interface{}, value interface{}) ArrayCondition + func LtAny(arr interface{}, value interface{}) ArrayCondition + func LteAll(arr interface{}, value interface{}) ArrayCondition + func LteAny(arr interface{}, value interface{}) ArrayCondition + func NeAll(arr interface{}, value interface{}) ArrayCondition + func NeAny(arr interface{}, value interface{}) ArrayCondition + func NotLikeANY(arr interface{}, value interface{}) ArrayCondition + func NotLikeAll(arr interface{}, value interface{}) ArrayCondition + func (array ArrayCondition) Parse() (asSQL string, bindings []interface{}) + type AuxStmt struct + As string + Stmt SQLStmt + type ConflictAction string + const DoNothing + const DoUpdate + type ConflictClause struct + Action ConflictAction + SetCols []string + SetVals []interface{} + Targets []string + Updates map[string]interface{} + func OnConflict(targets ...string) *ConflictClause + func (conflict *ConflictClause) DoNothing() *ConflictClause + func (conflict *ConflictClause) DoUpdate() *ConflictClause + func (conflict *ConflictClause) Set(col string, val interface{}) *ConflictClause + func (conflict *ConflictClause) SetIf(col string, val interface{}, b bool) *ConflictClause + func (conflict *ConflictClause) SetMap(vals map[string]interface{}) *ConflictClause + func (conflict *ConflictClause) ToSQL() (asSQL string, bindings []interface{}) + type DB struct + ErrHandlers []func(err error) + func New(db *sql.DB, driverName string, errHandlerFuncs ...func(err error)) *DB + func Newx(db *sqlx.DB) *DB + func (db *DB) DeleteFrom(table string) *DeleteStmt + func (db *DB) InsertInto(table string) *InsertStmt + func (db *DB) Select(cols ...string) *SelectStmt + func (db *DB) Set(configParam, value string) *SetCmd + func (db *DB) Transactional(f func(tx *Tx) error, opts ...*sql.TxOptions) error + func (db *DB) TransactionalContext(ctx context.Context, opts *sql.TxOptions, f func(tx *Tx) error) error + func (db *DB) Update(table string) *UpdateStmt + func (db *DB) With(stmt SQLStmt, as string) *WithStmt + type DeleteStmt struct + Conditions []WhereCondition + Return []string + Table string + UsingTables []string + func (stmt *DeleteStmt) Exec() (res sql.Result, err error) + func (stmt *DeleteStmt) ExecContext(ctx context.Context) (res sql.Result, err error) + func (stmt *DeleteStmt) GetAll(into interface{}) error + func (stmt *DeleteStmt) GetAllContext(ctx context.Context, into interface{}) error + func (stmt *DeleteStmt) GetRow(into interface{}) error + func (stmt *DeleteStmt) GetRowContext(ctx context.Context, into interface{}) error + func (stmt *DeleteStmt) Returning(cols ...string) *DeleteStmt + func (stmt *DeleteStmt) ToSQL(rebind bool) (asSQL string, bindings []interface{}) + func (stmt *DeleteStmt) Using(tables ...string) *DeleteStmt + func (stmt *DeleteStmt) Where(conds ...WhereCondition) *DeleteStmt + type Ext interface + type InCondition struct + Left string + NotIn bool + Right []interface{} + func In(col string, values ...interface{}) InCondition + func NotIn(col string, values ...interface{}) InCondition + func (in InCondition) Parse() (asSQL string, bindings []interface{}) + type IndirectValue struct + Bindings []interface{} + Reference string + func Indirect(value string, bindings ...interface{}) IndirectValue + func (i IndirectValue) ToSQL(_ bool) (string, []interface{}) + type InsertStmt struct + Conflicts []*ConflictClause + InsCols []string + InsMultipleVals [][]interface{} + InsVals []interface{} + Return []string + SelectStmt *SelectStmt + Table string + func (stmt *InsertStmt) Columns(cols ...string) *InsertStmt + func (stmt *InsertStmt) Exec() (res sql.Result, err error) + func (stmt *InsertStmt) ExecContext(ctx context.Context) (res sql.Result, err error) + func (stmt *InsertStmt) FromSelect(selStmt *SelectStmt) *InsertStmt + func (stmt *InsertStmt) GetAll(into interface{}) error + func (stmt *InsertStmt) GetAllContext(ctx context.Context, into interface{}) error + func (stmt *InsertStmt) GetRow(into interface{}) error + func (stmt *InsertStmt) GetRowContext(ctx context.Context, into interface{}) error + func (stmt *InsertStmt) OnConflict(clause *ConflictClause) *InsertStmt + func (stmt *InsertStmt) OnConflictDoNothing() *InsertStmt + func (stmt *InsertStmt) OrAbort() *InsertStmt + func (stmt *InsertStmt) OrFail() *InsertStmt + func (stmt *InsertStmt) OrIgnore() *InsertStmt + func (stmt *InsertStmt) OrReplace() *InsertStmt + func (stmt *InsertStmt) OrRollback() *InsertStmt + func (stmt *InsertStmt) Returning(cols ...string) *InsertStmt + func (stmt *InsertStmt) ToSQL(rebind bool) (asSQL string, bindings []interface{}) + func (stmt *InsertStmt) ValueMap(vals map[string]interface{}) *InsertStmt + func (stmt *InsertStmt) ValueMultiple(vals [][]interface{}) *InsertStmt + func (stmt *InsertStmt) Values(vals ...interface{}) *InsertStmt + type JSONBBuilder struct + Array bool + Bindings []interface{} + func BuildJSONBArray(in ...interface{}) (out JSONBBuilder) + func BuildJSONBObject(in map[string]interface{}) (out JSONBBuilder) + func (b JSONBBuilder) Parse() (asSQL string, bindings []interface{}) + type JSONBObject struct + Bindings []interface{} + type JoinClause struct + Conditions []WhereCondition + ResultSet *SelectStmt + Table string + Type JoinType + type JoinType string + func (j JoinType) IsLateral() bool + func (j JoinType) String() string + type LockClause struct + Strength LockStrength + Tables []string + Wait LockWait + func ForKeyShare() *LockClause + func ForNoKeyUpdate() *LockClause + func ForShare() *LockClause + func ForUpdate() *LockClause + func (lock *LockClause) NoWait() *LockClause + func (lock *LockClause) OfTables(tables ...string) *LockClause + func (lock *LockClause) SkipLocked() *LockClause + type LockStrength int8 + const LockForKeyShare + const LockForNoKeyUpdate + const LockForShare + const LockForUpdate + type LockWait int8 + const LockDefault + const LockNoWait + const LockSkipLocked + type OrderColumn struct + Column string + Desc bool + func Asc(col string) OrderColumn + func Desc(col string) OrderColumn + func (o OrderColumn) ToSQL(_ bool) (string, []interface{}) + type PreCondition struct + Condition WhereCondition + Pre string + func Not(cond WhereCondition) PreCondition + func (pre PreCondition) Parse() (asSQL string, bindings []interface{}) + type Queryer interface + type SQLCondition struct + Binds []interface{} + Condition string + func SQLCond(condition string, binds ...interface{}) SQLCondition + func (cond SQLCondition) Parse() (asSQL string, bindings []interface{}) + type SQLStmt interface + ToSQL func(bool) (string, []interface{}) + type SelectStmt struct + Columns []string + Conditions []WhereCondition + DistinctColumns []string + GroupConditions []WhereCondition + Grouping []string + IsDistinct bool + IsUnionAll bool + Joins []JoinClause + LimitTo int64 + Locks []*LockClause + OffsetFrom int64 + OffsetRows int64 + Ordering []SQLStmt + Table string + Unions []*SelectStmt + func (stmt *SelectStmt) Distinct(cols ...string) *SelectStmt + func (stmt *SelectStmt) From(table string) *SelectStmt + func (stmt *SelectStmt) FullJoin(table string, conds ...WhereCondition) *SelectStmt + func (stmt *SelectStmt) FullJoinRS(rs *SelectStmt, as string, conds ...WhereCondition) *SelectStmt + func (stmt *SelectStmt) GetAll(into interface{}) error + func (stmt *SelectStmt) GetAllAsMaps() (maps []map[string]interface{}, err error) + func (stmt *SelectStmt) GetAllAsRows() (rows *sqlx.Rows, err error) + func (stmt *SelectStmt) GetAllAsRowsContext(ctx context.Context) (rows *sqlx.Rows, err error) + func (stmt *SelectStmt) GetAllContext(ctx context.Context, into interface{}) error + func (stmt *SelectStmt) GetCount() (count int64, err error) + func (stmt *SelectStmt) GetCountContext(ctx context.Context) (count int64, err error) + func (stmt *SelectStmt) GetRow(into interface{}) error + func (stmt *SelectStmt) GetRowAsMap() (results map[string]interface{}, err error) + func (stmt *SelectStmt) GetRowContext(ctx context.Context, into interface{}) error + func (stmt *SelectStmt) GroupBy(cols ...string) *SelectStmt + func (stmt *SelectStmt) Having(conditions ...WhereCondition) *SelectStmt + func (stmt *SelectStmt) InnerJoin(table string, conds ...WhereCondition) *SelectStmt + func (stmt *SelectStmt) InnerJoinRS(rs *SelectStmt, as string, conds ...WhereCondition) *SelectStmt + func (stmt *SelectStmt) InnerLateralJoin(rs *SelectStmt, as string, conds ...WhereCondition) *SelectStmt + func (stmt *SelectStmt) Join(joinType JoinType, table string, resultSet *SelectStmt, ...) *SelectStmt + func (stmt *SelectStmt) LeftJoin(table string, conds ...WhereCondition) *SelectStmt + func (stmt *SelectStmt) LeftJoinRS(rs *SelectStmt, as string, conds ...WhereCondition) *SelectStmt + func (stmt *SelectStmt) LeftLateralJoin(rs *SelectStmt, as string, conds ...WhereCondition) *SelectStmt + func (stmt *SelectStmt) Limit(limit int64) *SelectStmt + func (stmt *SelectStmt) Lock(lock *LockClause) *SelectStmt + func (stmt *SelectStmt) Offset(start int64, rows ...int64) *SelectStmt + func (stmt *SelectStmt) OrderBy(cols ...SQLStmt) *SelectStmt + func (stmt *SelectStmt) RightJoin(table string, conds ...WhereCondition) *SelectStmt + func (stmt *SelectStmt) RightJoinRS(rs *SelectStmt, as string, conds ...WhereCondition) *SelectStmt + func (stmt *SelectStmt) RightLateralJoin(rs *SelectStmt, as string, conds ...WhereCondition) *SelectStmt + func (stmt *SelectStmt) ToSQL(rebind bool) (asSQL string, bindings []interface{}) + func (stmt *SelectStmt) Union(statements ...*SelectStmt) *SelectStmt + func (stmt *SelectStmt) UnionAll(statements ...*SelectStmt) *SelectStmt + func (stmt *SelectStmt) Where(conditions ...WhereCondition) *SelectStmt + func (stmt *SelectStmt) WithNullsFirst() *SelectStmt + func (stmt *SelectStmt) WithNullsLast() *SelectStmt + type SetCmd struct + func (cmd *SetCmd) Exec() (res sql.Result, err error) + func (cmd *SetCmd) Local() *SetCmd + func (cmd *SetCmd) Session() *SetCmd + func (cmd *SetCmd) ToSQL(rebind bool) (string, []interface{}) + type SimpleCondition struct + Left string + Operator string + Right interface{} + func Eq(col string, value interface{}) SimpleCondition + func Gt(col string, value interface{}) SimpleCondition + func Gte(col string, value interface{}) SimpleCondition + func ILike(col string, value interface{}) SimpleCondition + func IsNotNull(col string) SimpleCondition + func IsNull(col string) SimpleCondition + func JSONBOp(op string, left string, value interface{}) SimpleCondition + func Like(col string, value interface{}) SimpleCondition + func Lt(col string, value interface{}) SimpleCondition + func Lte(col string, value interface{}) SimpleCondition + func Ne(col string, value interface{}) SimpleCondition + func NotLike(col string, value interface{}) SimpleCondition + func (simple SimpleCondition) Parse() (asSQL string, bindings []interface{}) + type Statement struct + ErrHandlers []func(err error) + func (stmt *Statement) HandleError(err error) + type SubqueryCondition struct + Operator string + Stmt *SelectStmt + func Exists(stmt *SelectStmt) SubqueryCondition + func NotExists(stmt *SelectStmt) SubqueryCondition + func (subCond SubqueryCondition) Parse() (asSQL string, bindings []interface{}) + type Tx struct + ErrHandlers []func(err error) + func (tx *Tx) DeleteFrom(table string) *DeleteStmt + func (tx *Tx) InsertInto(table string) *InsertStmt + func (tx *Tx) Select(cols ...string) *SelectStmt + func (tx *Tx) Set(configParam, value string) *SetCmd + func (tx *Tx) SetTimeout(d time.Duration) (res sql.Result, err error) + func (tx *Tx) Update(table string) *UpdateStmt + func (tx *Tx) With(stmt SQLStmt, as string) *WithStmt + type UpdateFunction struct + Arguments []interface{} + Name string + func ArrayAppend(name string, value interface{}) UpdateFunction + func ArrayConcat(name string, value interface{}) UpdateFunction + func ArrayPrepend(name string, value interface{}) UpdateFunction + func ArrayRemove(name string, value interface{}) UpdateFunction + type UpdateStmt struct + Conditions []WhereCondition + Return []string + SelectStmt *SelectStmt + SelectStmtAlias string + Table string + Updates map[string]interface{} + func (stmt *UpdateStmt) Exec() (res sql.Result, err error) + func (stmt *UpdateStmt) ExecContext(ctx context.Context) (res sql.Result, err error) + func (stmt *UpdateStmt) FromSelect(selStmt *SelectStmt, alias string) *UpdateStmt + func (stmt *UpdateStmt) GetAll(into interface{}) error + func (stmt *UpdateStmt) GetAllContext(ctx context.Context, into interface{}) error + func (stmt *UpdateStmt) GetRow(into interface{}) error + func (stmt *UpdateStmt) GetRowContext(ctx context.Context, into interface{}) error + func (stmt *UpdateStmt) Returning(cols ...string) *UpdateStmt + func (stmt *UpdateStmt) Set(col string, value interface{}) *UpdateStmt + func (stmt *UpdateStmt) SetIf(col string, value interface{}, b bool) *UpdateStmt + func (stmt *UpdateStmt) SetMap(updates map[string]interface{}) *UpdateStmt + func (stmt *UpdateStmt) ToSQL(rebind bool) (asSQL string, bindings []interface{}) + func (stmt *UpdateStmt) Where(conditions ...WhereCondition) *UpdateStmt + type WhereCondition interface + Parse func() (asSQL string, bindings []interface{}) + type WithStmt struct + AuxStmts []AuxStmt + MainStmt SQLStmt + func (stmt *WithStmt) And(auxStmt SQLStmt, as string) *WithStmt + func (stmt *WithStmt) Exec() (res sql.Result, err error) + func (stmt *WithStmt) ExecContext(ctx context.Context) (res sql.Result, err error) + func (stmt *WithStmt) GetAll(into interface{}) error + func (stmt *WithStmt) GetAllAsRows() (rows *sqlx.Rows, err error) + func (stmt *WithStmt) GetAllContext(ctx context.Context, into interface{}) error + func (stmt *WithStmt) GetRow(into interface{}) error + func (stmt *WithStmt) GetRowContext(ctx context.Context, into interface{}) error + func (stmt *WithStmt) Then(mainStmt SQLStmt) *WithStmt + func (stmt *WithStmt) ToSQL(rebind bool) (asSQL string, bindings []interface{})