Versions in this module Expand all Collapse all v0 v0.7.1 Nov 2, 2021 v0.7.0 Jul 22, 2021 Changes in this version + const MYSQL + const POSTGRES + var ErrCantConvertToTime = errors.New("can't convert to time.Time") + var ErrColumnNotSpecified = errors.New("column not specified") + var ErrInvalidPointer = errors.New("attempt to load into an invalid pointer") + var ErrInvalidSliceLength = errors.New("length of slice is 0. length must be >= 1") + var ErrInvalidTimestring = errors.New("invalid time string") + var ErrNotFound = errors.New("not found") + var ErrNotSupported = errors.New("not supported") + var ErrPlaceholderCount = errors.New("wrong placeholder count") + var ErrTableNotSpecified = errors.New("table not specified") + var NameMapping = camelCaseToSnakeCase + var Now = nowSentinel + func GetTagColumns(structValue interface{}) []string + func InterfaceLoader(value, 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 + 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 + func (b BuildFunc) ToSQL(d Dialect, buf Buffer) error + type Builder interface + Build func(Dialect, Buffer) error + ToSQL 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 (c Comments) Append(comment string) Comments + func (c Comments) Build(d Dialect, buf Buffer) error + 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) Limit(n uint64) *DeleteStmt + func (b *DeleteStmt) ToSQL(d Dialect, i Buffer) error + 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 Driver interface + Exec func(query string, args ...interface{}) (sql.Result, error) + ExecContext func(ctx context.Context, query string, args ...interface{}) (sql.Result, error) + Query func(query string, args ...interface{}) (*sql.Rows, error) + QueryContext func(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) + QueryRow func(query string, args ...interface{}) *sql.Row + QueryRowContext func(ctx context.Context, query string, args ...interface{}) *sql.Row + type Error struct + Code string + Message string + func CatchErr(err error) *Error + func (e *Error) Error() string + type Event struct + Data interface{} + Type EventType + type EventFunc func(Event) + type EventHandler struct + Event Event + EventMap EventMap + func NewEventHandler() *EventHandler + func (h *EventHandler) Dispatcher(ctx context.Context) + func (h *EventHandler) Handle(ctx context.Context, e EventType, f EventFunc) + func (h *EventHandler) Notify(ctx context.Context, event Event) + type EventMap map[EventType][]EventFunc + type EventType string + const CreatedQuery + const DeletedQuery + const ReadQuery + const UpdatedQuery + 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) Ignore() *InsertStmt + 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) ToSQL(d Dialect, i Buffer) error + func (b *InsertStmt) Values(value ...interface{}) *InsertStmt + type NullBool struct + func NewNullBool(v interface{}) (n NullBool) + func (n *NullBool) UnmarshalJSON(b []byte) error + func (n NullBool) MarshalJSON() ([]byte, error) + 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 Query struct + 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) Join(table, on interface{}) *SelectStmt + func (b *SelectStmt) LeftJoin(table, on interface{}) *SelectStmt + func (b *SelectStmt) Limit(n uint64) *SelectStmt + 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) RightJoin(table, on interface{}) *SelectStmt + func (b *SelectStmt) Seek(column string, cursor, limit uint64) *SelectStmt + func (b *SelectStmt) Suffix(suffix string, value ...interface{}) *SelectStmt + func (b *SelectStmt) ToSQL(d Dialect, i Buffer) error + func (b *SelectStmt) Where(query interface{}, value ...interface{}) *SelectStmt + type Sql struct + Event *EventHandler + func New(args SqlConnParams) (*Sql, error) + func (s *Sql) Notify(ctx context.Context, event Event) + func (s *Sql) SetEvent(handler *EventHandler) + func (s *Sql) Subscriber(ctx context.Context, t EventType, fn EventFunc) + func (s *Sql) WithTransaction(ctx context.Context, fn func(context.Context, *sql.Tx) error) error + type SqlConnParams struct + Driver string + Dsn string + type Store interface + Notify func(ctx context.Context, event Event) + Subscriber func(ctx context.Context, t EventType, fn EventFunc) + WithTransaction func(ctx context.Context, fn func(ctx context.Context, tx *sql.Tx) error) error + 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) IncrBy(column string, value interface{}) *UpdateStmt + func (b *UpdateStmt) Limit(n uint64) *UpdateStmt + 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) ToSQL(d Dialect, i Buffer) error + func (b *UpdateStmt) Where(query interface{}, value ...interface{}) *UpdateStmt