Documentation
¶
Index ¶
- Constants
- Variables
- func BindBinaryValue(value Any) (Any, bool)
- func BindJSONValue(value Any) (Any, bool)
- func BindTextValue(value Any) (Any, bool)
- func BindTimeValue(value Any) (Any, bool)
- func BuildGroupBy(fields []string, dialect Dialect) string
- func BuildLimitOffset(q Query, startIndex int, dialect Dialect, args *[]Any) string
- func BuildOrderBy(q Query, dialect Dialect) string
- func CacheToken(name string, tables []string) string
- func CamelFieldPath(field string) string
- func DecodeBinaryValue(value Any) (Any, bool)
- func DecodeJSONValue(value Any) (Any, bool)
- func DecodePGArrayValue(cfg Var, value Any) (Any, bool)
- func DecodeTextValue(value Any) (Any, bool)
- func DecodeTimeValue(value Any) (Any, bool)
- func EmitMutation(base, table, op string, rows int64, key Any, keys []Any, data Map, where Map)
- func Error(op string, code error, err error) error
- func ErrorKind(err error) string
- func Field(name string, field string, extends ...Any) Var
- func Fields(name string, keys []string, extends ...Vars) Vars
- func GenerateTableKeys(tableName string, table Table) string
- func IsArrayVar(cfg Var) bool
- func IsBinaryVar(cfg Var) bool
- func IsDecimalVar(cfg Var) bool
- func IsJSONVar(cfg Var) bool
- func IsTimeVar(cfg Var) bool
- func IsUUIDVar(cfg Var) bool
- func Migrate(names ...string) error
- func MigrateDown(steps int) error
- func MigrateDownOn(base string, steps int) error
- func MigrateOn(base string, names ...string) error
- func MigrateUp(versions ...string) error
- func MigrateUpOn(base string, versions ...string) error
- func Models() map[string]Model
- func Option(name string, field string, key string) Any
- func Options(name string, field string) Map
- func QuerySignature(q Query) string
- func Sequence(key string, offset, step int64, names ...string) (int64, error)
- func SequenceMany(key string, count, offset, step int64, names ...string) ([]int64, error)
- func SnakeFieldPath(field string) string
- func Tables() map[string]Table
- func TouchTableCache(name, table string) uint64
- func Views() map[string]View
- type Agg
- type AndExpr
- type ArrayBinder
- type Capabilities
- type Cascade
- type CmpExpr
- type Config
- type Configs
- type Connection
- type DataBase
- type DataError
- type DataModel
- type DataTable
- type DataView
- type DeleteWatcher
- type Dialect
- type Driver
- type ErrorClassifier
- type ExistsExpr
- type Expr
- type FieldRef
- type Health
- type Index
- type InsertWatcher
- type Instance
- type Join
- type MigrateAction
- type MigrateDelta
- type MigrateOptions
- type MigrateReport
- type Migration
- type Model
- type Module
- func (m *Module) Base(names ...string) DataBase
- func (m *Module) Close()
- func (m *Module) Config(global Map)
- func (m *Module) Field(name, field string, extends ...Any) Var
- func (m *Module) Fields(name string, keys []string, extends ...Vars) Vars
- func (m *Module) GetCapabilities(names ...string) (Capabilities, error)
- func (m *Module) ModelConfig(name string) *Model
- func (m *Module) Models() map[string]Model
- func (m *Module) Open()
- func (m *Module) Option(name, field, key string) Any
- func (m *Module) Options(name, field string) Map
- func (m *Module) PoolStats(names ...string) []PoolStats
- func (m *Module) Register(name string, value Any)
- func (m *Module) RegisterConfig(name string, cfg Config)
- func (m *Module) RegisterConfigs(configs Configs)
- func (m *Module) RegisterDeleteWatcher(name string, watcher DeleteWatcher)
- func (m *Module) RegisterDriver(name string, driver Driver)
- func (m *Module) RegisterInsertWatcher(name string, watcher InsertWatcher)
- func (m *Module) RegisterMigration(name string, migration Migration)
- func (m *Module) RegisterModel(name string, model Model)
- func (m *Module) RegisterTable(name string, table Table)
- func (m *Module) RegisterUpdateWatcher(name string, watcher UpdateWatcher)
- func (m *Module) RegisterUpsertWatcher(name string, watcher UpsertWatcher)
- func (m *Module) RegisterView(name string, view View)
- func (m *Module) RegisterWatcher(name string, watcher Watcher)
- func (m *Module) RegisterWatchers(items Watchers)
- func (m *Module) Setup()
- func (m *Module) Start()
- func (m *Module) Stats(names ...string) Stats
- func (m *Module) Stop()
- func (m *Module) TableConfig(name string) *Table
- func (m *Module) Tables() map[string]Table
- func (m *Module) ViewConfig(name string) *View
- func (m *Module) Views() map[string]View
- type Mutation
- type NotExpr
- type NullExpr
- type OrExpr
- type ParameterLimiter
- type PlanOptions
- type PoolStats
- type Query
- type RawExpr
- type SQLBuilder
- type ScanFunc
- type Sort
- type Stats
- type Table
- type TrashOptions
- type TrueExpr
- type TxFunc
- type UpdateWatcher
- type UpsertWatcher
- type ValueBinder
- type ValueDecoder
- type View
- type Watcher
- type Watchers
Constants ¶
View Source
const ( MutationInsert = "insert" MutationUpdate = "update" MutationDelete = "delete" MutationUpsert = "upsert" // Short op aliases (kept for concise usage). INSERT = MutationInsert UPDATE = MutationUpdate DEL = MutationDelete UPSERT = MutationUpsert )
View Source
const NAME = "DATA"
Variables ¶
View Source
var ( ErrNotFound = errors.New("data: not found") ErrConflict = errors.New("data: conflict") ErrDuplicate = errors.New("data: duplicate") ErrForeignKey = errors.New("data: foreign key") ErrUnsupported = errors.New("data: unsupported") ErrInvalidQuery = errors.New("data: invalid query") ErrInvalidUpdate = errors.New("data: invalid update") ErrInvalidSequence = errors.New("data: invalid sequence") ErrTxFailed = errors.New("data: tx failed") ErrValidation = errors.New("data: validation") ErrDriver = errors.New("data: driver") ErrTimeout = errors.New("data: timeout") ErrCanceled = errors.New("data: canceled") )
Functions ¶
func BindBinaryValue ¶ added in v0.26.0
func BindBinaryValue(value Any) (Any, bool)
func BindJSONValue ¶ added in v0.26.0
func BindJSONValue(value Any) (Any, bool)
func BindTextValue ¶ added in v0.26.0
func BindTextValue(value Any) (Any, bool)
func BindTimeValue ¶ added in v0.26.0
func BindTimeValue(value Any) (Any, bool)
func BuildGroupBy ¶ added in v0.7.0
func BuildLimitOffset ¶ added in v0.7.0
func BuildOrderBy ¶ added in v0.7.0
func CacheToken ¶ added in v0.7.0
func CamelFieldPath ¶ added in v0.7.0
func DecodeBinaryValue ¶ added in v0.26.0
func DecodeBinaryValue(value Any) (Any, bool)
func DecodeJSONValue ¶ added in v0.26.0
func DecodeJSONValue(value Any) (Any, bool)
func DecodePGArrayValue ¶ added in v0.26.0
func DecodePGArrayValue(cfg Var, value Any) (Any, bool)
func DecodeTextValue ¶ added in v0.26.0
func DecodeTextValue(value Any) (Any, bool)
func DecodeTimeValue ¶ added in v0.26.0
func DecodeTimeValue(value Any) (Any, bool)
func EmitMutation ¶ added in v0.7.0
func GenerateTableKeys ¶ added in v0.7.0
GenerateTableKeys emits a compact Go constant block for table field names. It helps projects avoid manual string literals in query/update code.
func IsArrayVar ¶ added in v0.26.0
func IsArrayVar(cfg Var) bool
func IsBinaryVar ¶ added in v0.26.0
func IsBinaryVar(cfg Var) bool
func IsDecimalVar ¶ added in v0.26.0
func IsDecimalVar(cfg Var) bool
func MigrateDown ¶ added in v0.7.0
func MigrateDownOn ¶ added in v0.7.0
func MigrateUpOn ¶ added in v0.7.0
func QuerySignature ¶ added in v0.7.0
func SequenceMany ¶ added in v0.21.0
func SnakeFieldPath ¶ added in v0.7.0
func TouchTableCache ¶ added in v0.7.0
Types ¶
type ArrayBinder ¶ added in v0.26.0
type Capabilities ¶ added in v0.7.0
type Capabilities struct {
Dialect string `json:"dialect"`
ILike bool `json:"ilike"`
Returning bool `json:"returning"`
Join bool `json:"join"`
Group bool `json:"group"`
Having bool `json:"having"`
Aggregate bool `json:"aggregate"`
KeysetAfter bool `json:"keyset_after"`
JsonContains bool `json:"json_contains"`
ArrayOverlap bool `json:"array_overlap"`
JsonElemMatch bool `json:"json_elem_match"`
}
func GetCapabilities ¶ added in v0.7.0
func GetCapabilities(names ...string) (Capabilities, error)
type Connection ¶ added in v0.7.0
type DataBase ¶
type DataBase interface {
Close() error
WithContext(context.Context) DataBase
WithTimeout(time.Duration) DataBase
Begin() error
Commit() error
Rollback() error
Tx(TxFunc) Res
TxReadOnly(TxFunc) Res
Migrate(...string)
MigratePlan(...string) MigrateReport
MigrateDiff(...string) MigrateReport
MigrateUp(...string)
MigrateDown(int)
MigrateTo(string)
MigrateDownTo(string)
Capabilities() Capabilities
Error() error
ClearError()
Sequence(string, int64, int64) (int64, error)
SequenceMany(string, int64, int64, int64) ([]int64, error)
Table(string) DataTable
View(string) DataView
Model(string) DataModel
Raw(string, ...Any) []Map
Exec(string, ...Any) int64
Parse(...Any) (string, []Any)
}
type DataTable ¶
type DataTable interface {
Insert(Map) Map
InsertMany([]Map) []Map
Upsert(Map, ...Any) Map
UpsertMany([]Map, ...Any) []Map
Update(Map, ...Any) Map
UpdateMany(Map, ...Any) int64
Remove(...Any) Map
RemoveMany(...Any) int64
Restore(...Any) Map
RestoreMany(...Any) int64
Delete(...Any) Map
DeleteMany(...Any) int64
Entity(Any) Map
Count(...Any) int64
Aggregate(...Any) []Map
First(...Any) Map
Query(...Any) []Map
Scan(ScanFunc, ...Any) Res
ScanN(int64, ScanFunc, ...Any) Res
Slice(offset, limit int64, args ...Any) (int64, []Map)
Group(field string, args ...Any) []Map
}
type DeleteWatcher ¶ added in v0.7.0
type Driver ¶
type Driver interface {
Connect(*Instance) (Connection, error)
}
type ErrorClassifier ¶ added in v0.26.0
type ExistsExpr ¶ added in v0.7.0
type InsertWatcher ¶ added in v0.7.0
type MigrateAction ¶ added in v0.7.0
type MigrateDelta ¶ added in v0.26.0
type MigrateOptions ¶ added in v0.7.0
type MigrateReport ¶ added in v0.7.0
type MigrateReport struct {
Mode string `json:"mode"`
DryRun bool `json:"dryRun"`
Actions []MigrateAction `json:"actions"`
}
func MigrateDiff ¶ added in v0.7.0
func MigrateDiff(names ...string) (MigrateReport, error)
func MigrateDiffOn ¶ added in v0.7.0
func MigrateDiffOn(base string, names ...string) (MigrateReport, error)
func MigratePlan ¶ added in v0.7.0
func MigratePlan(names ...string) (MigrateReport, error)
func MigratePlanOn ¶ added in v0.7.0
func MigratePlanOn(base string, names ...string) (MigrateReport, error)
type Migration ¶ added in v0.7.0
type Migration struct {
Version string
Name string
Desc string
Up func(DataBase) error
Down func(DataBase) error
}
func Migrations ¶ added in v0.7.0
type Model ¶
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
func (*Module) GetCapabilities ¶ added in v0.7.0
func (m *Module) GetCapabilities(names ...string) (Capabilities, error)
func (*Module) ModelConfig ¶
func (*Module) RegisterConfig ¶ added in v0.7.0
func (*Module) RegisterConfigs ¶ added in v0.7.0
func (*Module) RegisterDeleteWatcher ¶ added in v0.7.0
func (m *Module) RegisterDeleteWatcher(name string, watcher DeleteWatcher)
func (*Module) RegisterDriver ¶ added in v0.7.0
func (*Module) RegisterInsertWatcher ¶ added in v0.7.0
func (m *Module) RegisterInsertWatcher(name string, watcher InsertWatcher)
func (*Module) RegisterMigration ¶ added in v0.7.0
func (*Module) RegisterModel ¶ added in v0.7.0
func (*Module) RegisterTable ¶ added in v0.7.0
func (*Module) RegisterUpdateWatcher ¶ added in v0.7.0
func (m *Module) RegisterUpdateWatcher(name string, watcher UpdateWatcher)
func (*Module) RegisterUpsertWatcher ¶ added in v0.7.0
func (m *Module) RegisterUpsertWatcher(name string, watcher UpsertWatcher)
func (*Module) RegisterView ¶ added in v0.7.0
func (*Module) RegisterWatcher ¶ added in v0.7.0
func (*Module) RegisterWatchers ¶ added in v0.7.0
func (*Module) TableConfig ¶
func (*Module) ViewConfig ¶
type ParameterLimiter ¶ added in v0.26.0
type ParameterLimiter interface {
MaxParams() int
}
type PlanOptions ¶ added in v0.7.0
type PoolStats ¶ added in v0.7.0
type PoolStats struct {
Name string `json:"name"`
Driver string `json:"driver"`
Open int `json:"open"`
InUse int `json:"inUse"`
Idle int `json:"idle"`
WaitCount int64 `json:"waitCount"`
WaitDuration int64 `json:"waitDurationMs"`
MaxOpen int `json:"maxOpen"`
Queries int64 `json:"queries"`
Writes int64 `json:"writes"`
Errors int64 `json:"errors"`
CacheHit int64 `json:"cacheHit"`
CacheRate float64 `json:"cacheRate"`
Slow int64 `json:"slow"`
SlowAvgMs int64 `json:"slowAvgMs"`
SlowP50Ms int64 `json:"slowP50Ms"`
SlowP95Ms int64 `json:"slowP95Ms"`
}
func GetPoolStats ¶ added in v0.7.0
type Query ¶ added in v0.7.0
type Query struct {
Select []string
Filter Expr
Sort []Sort
Limit int64
Offset int64
After Map
WithCount bool
WithDeleted bool
OnlyDeleted bool
Unscoped bool
Unsafe bool
Batch int64
Group []string
Aggs []Agg
Having Expr
Joins []Join
RawWhere string
RawParams []Any
}
func ParseQuery ¶ added in v0.7.0
type SQLBuilder ¶ added in v0.7.0
type SQLBuilder struct {
// contains filtered or unexported fields
}
func NewSQLBuilder ¶ added in v0.7.0
func NewSQLBuilder(d Dialect) *SQLBuilder
func (*SQLBuilder) Args ¶ added in v0.7.0
func (b *SQLBuilder) Args() []Any
func (*SQLBuilder) CompileExpr ¶ added in v0.7.0
func (b *SQLBuilder) CompileExpr(e Expr) (string, error)
func (*SQLBuilder) CompileWhere ¶ added in v0.7.0
func (b *SQLBuilder) CompileWhere(q Query) (string, []Any, error)
type Stats ¶ added in v0.7.0
type Stats struct {
Queries int64 `json:"queries"`
Writes int64 `json:"writes"`
Errors int64 `json:"errors"`
Slow int64 `json:"slow"`
CacheHit int64 `json:"cacheHit"`
CacheMiss int64 `json:"cacheMiss"`
CacheFlight int64 `json:"cacheFlight"`
CacheWait int64 `json:"cacheWait"`
CacheRate float64 `json:"cacheRate"`
SlowAvgMs int64 `json:"slowAvgMs"`
SlowP50Ms int64 `json:"slowP50Ms"`
SlowP95Ms int64 `json:"slowP95Ms"`
ChangeIn int64 `json:"changeIn"`
ChangeDrop int64 `json:"changeDrop"`
ChangeFail int64 `json:"changeFail"`
}
type Table ¶
type TrashOptions ¶ added in v0.12.0
type UpdateWatcher ¶ added in v0.7.0
type UpsertWatcher ¶ added in v0.7.0
type ValueBinder ¶ added in v0.26.0
type ValueDecoder ¶ added in v0.26.0
type View ¶
Click to show internal directories.
Click to hide internal directories.