Versions in this module Expand all Collapse all v2 v2.8.0 Mar 19, 2022 Changes in this version + var ErrCantConvertToTime = errors.New("dbr: can't convert to time.Time") + var ErrColumnNotSpecified = errors.New("dbr: column not specified") + var ErrInvalidPointer = errors.New("dbr: attempt to load into an invalid pointer") + var ErrInvalidSliceLength = errors.New("dbr: length of slice is 0. length must be >= 1") + var ErrInvalidTimestring = errors.New("dbr: invalid time string") + var ErrNotFound = errors.New("dbr: not found") + var ErrNotSupported = errors.New("dbr: not supported") + var ErrPlaceholderCount = errors.New("dbr: wrong placeholder count") + var ErrTableNotSpecified = errors.New("dbr: table not specified") + var NameMapping = camelCaseToSnakeCase + var Now = nowSentinel + func ForceIndex(index ...string) indexHint + func IgnoreIndex(index ...string) indexHint + func InterfaceLoader(value interface{}, concreteType interface{}) interface + func InterpolateForDialect(query string, value []interface{}, d Dialect) (string, error) + func Load(rows *sql.Rows, value interface{}) (int, error) + func Union(builder ...Builder) interface + func UnionAll(builder ...Builder) interface + func UseIndex(index ...string) indexHint + type Buffer interface + String func() string + Value func() []interface{} + WriteString func(string) (int, error) + WriteValue func(v ...interface{}) (err error) + func NewBuffer() Buffer + type BuildFunc func(Dialect, Buffer) error + func (b BuildFunc) Build(d Dialect, buf Buffer) error + type Builder interface + Build func(Dialect, Buffer) error + func And(cond ...Builder) Builder + func Eq(column string, value interface{}) Builder + func Expr(query string, value ...interface{}) Builder + func Gt(column string, value interface{}) Builder + func Gte(column string, value interface{}) Builder + func Like(column, value string, escape ...string) Builder + func Lt(column string, value interface{}) Builder + func Lte(column string, value interface{}) Builder + func Neq(column string, value interface{}) Builder + func NotLike(column, value string, escape ...string) Builder + func Or(cond ...Builder) Builder + type Comments []string + func (comments Comments) Append(comment string) Comments + func (comments Comments) Build(d Dialect, buf Buffer) error + type Connection struct + func Open(driver, dsn string, log EventReceiver) (*Connection, error) + func (conn *Connection) NewSession(log EventReceiver) *Session + type DeleteBuilder = DeleteStmt + type DeleteStmt struct + LimitCount int64 + Table string + WhereCond []Builder + func DeleteBySql(query string, value ...interface{}) *DeleteStmt + func DeleteFrom(table string) *DeleteStmt + func (b *DeleteStmt) Build(d Dialect, buf Buffer) error + func (b *DeleteStmt) Comment(comment string) *DeleteStmt + func (b *DeleteStmt) Exec() (sql.Result, error) + func (b *DeleteStmt) ExecContext(ctx context.Context) (sql.Result, error) + func (b *DeleteStmt) Limit(n uint64) *DeleteStmt + func (b *DeleteStmt) Where(query interface{}, value ...interface{}) *DeleteStmt + type Dialect interface + EncodeBool func(b bool) string + EncodeBytes func(b []byte) string + EncodeString func(s string) string + EncodeTime func(t time.Time) string + Placeholder func(n int) string + QuoteIdent func(id string) string + type EventReceiver interface + Event func(eventName string) + EventErr func(eventName string, err error) error + EventErrKv func(eventName string, err error, kvs map[string]string) error + EventKv func(eventName string, kvs map[string]string) + Timing func(eventName string, nanoseconds int64) + TimingKv func(eventName string, nanoseconds int64, kvs map[string]string) + type I string + func (i I) As(alias string) Builder + func (i I) Build(d Dialect, buf Buffer) error + type InsertBuilder = InsertStmt + type InsertStmt struct + Column []string + Ignored bool + RecordID *int64 + ReturnColumn []string + Table string + Value [][]interface{} + func InsertBySql(query string, value ...interface{}) *InsertStmt + func InsertInto(table string) *InsertStmt + func (b *InsertStmt) Build(d Dialect, buf Buffer) error + func (b *InsertStmt) Columns(column ...string) *InsertStmt + func (b *InsertStmt) Comment(comment string) *InsertStmt + func (b *InsertStmt) Exec() (sql.Result, error) + func (b *InsertStmt) ExecContext(ctx context.Context) (sql.Result, error) + func (b *InsertStmt) Ignore() *InsertStmt + func (b *InsertStmt) Load(value interface{}) error + func (b *InsertStmt) LoadContext(ctx context.Context, value interface{}) error + func (b *InsertStmt) Pair(column string, value interface{}) *InsertStmt + func (b *InsertStmt) Record(structValue interface{}) *InsertStmt + func (b *InsertStmt) Returning(column ...string) *InsertStmt + func (b *InsertStmt) Values(value ...interface{}) *InsertStmt + type Iterator interface + Close func() error + Err func() error + Next func() bool + Scan func(interface{}) error + type NullBool struct + func NewNullBool(v interface{}) (n NullBool) + func (n *NullBool) UnmarshalJSON(b []byte) error + func (n NullBool) MarshalJSON() ([]byte, error) + type NullEventReceiver struct + func (n *NullEventReceiver) Event(eventName string) + func (n *NullEventReceiver) EventErr(eventName string, err error) error + func (n *NullEventReceiver) EventErrKv(eventName string, err error, kvs map[string]string) error + func (n *NullEventReceiver) EventKv(eventName string, kvs map[string]string) + func (n *NullEventReceiver) Timing(eventName string, nanoseconds int64) + func (n *NullEventReceiver) TimingKv(eventName string, nanoseconds int64, kvs map[string]string) + type NullFloat64 struct + func NewNullFloat64(v interface{}) (n NullFloat64) + func (n *NullFloat64) UnmarshalJSON(b []byte) error + func (n NullFloat64) MarshalJSON() ([]byte, error) + type NullInt64 struct + func NewNullInt64(v interface{}) (n NullInt64) + func (n *NullInt64) UnmarshalJSON(b []byte) error + func (n NullInt64) MarshalJSON() ([]byte, error) + type NullString struct + func NewNullString(v interface{}) (n NullString) + func (n *NullString) UnmarshalJSON(b []byte) error + func (n NullString) MarshalJSON() ([]byte, error) + type NullTime struct + Time time.Time + Valid bool + func NewNullTime(v interface{}) (n NullTime) + func (n *NullTime) Scan(value interface{}) error + func (n *NullTime) UnmarshalJSON(b []byte) error + func (n NullTime) MarshalJSON() ([]byte, error) + func (n NullTime) Value() (driver.Value, error) + type SelectBuilder = SelectStmt + type SelectStmt struct + Column []interface{} + Group []Builder + HavingCond []Builder + IsDistinct bool + JoinTable []Builder + LimitCount int64 + OffsetCount int64 + Order []Builder + Suffixes []Builder + Table interface{} + WhereCond []Builder + func Select(column ...interface{}) *SelectStmt + func SelectBySql(query string, value ...interface{}) *SelectStmt + func (b *SelectStmt) As(alias string) Builder + func (b *SelectStmt) Build(d Dialect, buf Buffer) error + func (b *SelectStmt) Comment(comment string) *SelectStmt + func (b *SelectStmt) Distinct() *SelectStmt + func (b *SelectStmt) From(table interface{}) *SelectStmt + func (b *SelectStmt) FullJoin(table, on interface{}) *SelectStmt + func (b *SelectStmt) GroupBy(col ...string) *SelectStmt + func (b *SelectStmt) Having(query interface{}, value ...interface{}) *SelectStmt + func (b *SelectStmt) IndexHint(hints ...interface{}) *SelectStmt + func (b *SelectStmt) Iterate() (Iterator, error) + func (b *SelectStmt) IterateContext(ctx context.Context) (Iterator, error) + func (b *SelectStmt) Join(table, on interface{}) *SelectStmt + func (b *SelectStmt) LeftJoin(table, on interface{}) *SelectStmt + func (b *SelectStmt) Limit(n uint64) *SelectStmt + func (b *SelectStmt) Load(value interface{}) (int, error) + func (b *SelectStmt) LoadContext(ctx context.Context, value interface{}) (int, error) + func (b *SelectStmt) LoadOne(value interface{}) error + func (b *SelectStmt) LoadOneContext(ctx context.Context, value interface{}) error + func (b *SelectStmt) Offset(n uint64) *SelectStmt + func (b *SelectStmt) OrderAsc(col string) *SelectStmt + func (b *SelectStmt) OrderBy(col string) *SelectStmt + func (b *SelectStmt) OrderDesc(col string) *SelectStmt + func (b *SelectStmt) OrderDir(col string, isAsc bool) *SelectStmt + func (b *SelectStmt) Paginate(page, perPage uint64) *SelectStmt + func (b *SelectStmt) ReturnInt64() (int64, error) + func (b *SelectStmt) ReturnInt64s() ([]int64, error) + func (b *SelectStmt) ReturnString() (string, error) + func (b *SelectStmt) ReturnStrings() ([]string, error) + func (b *SelectStmt) ReturnUint64() (uint64, error) + func (b *SelectStmt) ReturnUint64s() ([]uint64, error) + func (b *SelectStmt) RightJoin(table, on interface{}) *SelectStmt + func (b *SelectStmt) Rows() (*sql.Rows, error) + func (b *SelectStmt) RowsContext(ctx context.Context) (*sql.Rows, error) + func (b *SelectStmt) Suffix(suffix string, value ...interface{}) *SelectStmt + func (b *SelectStmt) Where(query interface{}, value ...interface{}) *SelectStmt + type Session struct + Timeout time.Duration + func (sess *Session) Begin() (*Tx, error) + func (sess *Session) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) + func (sess *Session) DeleteBySql(query string, value ...interface{}) *DeleteStmt + func (sess *Session) DeleteFrom(table string) *DeleteStmt + func (sess *Session) GetTimeout() time.Duration + func (sess *Session) InsertBySql(query string, value ...interface{}) *InsertStmt + func (sess *Session) InsertInto(table string) *InsertStmt + func (sess *Session) Select(column ...string) *SelectStmt + func (sess *Session) SelectBySql(query string, value ...interface{}) *SelectStmt + func (sess *Session) Update(table string) *UpdateStmt + func (sess *Session) UpdateBySql(query string, value ...interface{}) *UpdateStmt + type SessionRunner interface + DeleteBySql func(query string, value ...interface{}) *DeleteBuilder + DeleteFrom func(table string) *DeleteBuilder + InsertBySql func(query string, value ...interface{}) *InsertBuilder + InsertInto func(table string) *InsertBuilder + Select func(column ...string) *SelectBuilder + SelectBySql func(query string, value ...interface{}) *SelectBuilder + Update func(table string) *UpdateBuilder + UpdateBySql func(query string, value ...interface{}) *UpdateBuilder + type TracingEventReceiver interface + SpanError func(ctx context.Context, err error) + SpanFinish func(ctx context.Context) + SpanStart func(ctx context.Context, eventName, query string) context.Context + type Tx struct + Timeout time.Duration + func (tx *Tx) Commit() error + func (tx *Tx) DeleteBySql(query string, value ...interface{}) *DeleteStmt + func (tx *Tx) DeleteFrom(table string) *DeleteStmt + func (tx *Tx) GetTimeout() time.Duration + func (tx *Tx) InsertBySql(query string, value ...interface{}) *InsertStmt + func (tx *Tx) InsertInto(table string) *InsertStmt + func (tx *Tx) Rollback() error + func (tx *Tx) RollbackUnlessCommitted() + func (tx *Tx) Select(column ...string) *SelectStmt + func (tx *Tx) SelectBySql(query string, value ...interface{}) *SelectStmt + func (tx *Tx) Update(table string) *UpdateStmt + func (tx *Tx) UpdateBySql(query string, value ...interface{}) *UpdateStmt + type UpdateBuilder = UpdateStmt + type UpdateStmt struct + LimitCount int64 + ReturnColumn []string + Table string + Value map[string]interface{} + WhereCond []Builder + func Update(table string) *UpdateStmt + func UpdateBySql(query string, value ...interface{}) *UpdateStmt + func (b *UpdateStmt) Build(d Dialect, buf Buffer) error + func (b *UpdateStmt) Comment(comment string) *UpdateStmt + func (b *UpdateStmt) DecrBy(column string, value interface{}) *UpdateStmt + func (b *UpdateStmt) Exec() (sql.Result, error) + func (b *UpdateStmt) ExecContext(ctx context.Context) (sql.Result, error) + func (b *UpdateStmt) IncrBy(column string, value interface{}) *UpdateStmt + func (b *UpdateStmt) IndexHint(hints ...interface{}) *UpdateStmt + func (b *UpdateStmt) Limit(n uint64) *UpdateStmt + func (b *UpdateStmt) Load(value interface{}) error + func (b *UpdateStmt) LoadContext(ctx context.Context, value interface{}) error + func (b *UpdateStmt) Returning(column ...string) *UpdateStmt + func (b *UpdateStmt) Set(column string, value interface{}) *UpdateStmt + func (b *UpdateStmt) SetMap(m map[string]interface{}) *UpdateStmt + func (b *UpdateStmt) Where(query interface{}, value ...interface{}) *UpdateStmt