Documentation ¶
Index ¶
- Variables
- func AsFloat(e any) (n float64, ok bool)
- func AsInt(e any) (n int64, ok bool)
- func DictSet(key string, value ...string)
- func Instance[T any]() (v T)
- func MaybeTable(e any) (ok bool)
- func MaybeView(e any) (ok bool)
- func NewBasicValueWriter(rt reflect.Type) (vw ValueWriter, ct ColumnTypeName, err error)
- func RegisterDialect(dialect Dialect)
- func ScanRows[T any](ctx context.Context, rows sql.Rows, fields []string) (entries []T, err error)
- func TrySetupAuditCreation[T any](ctx context.Context, spec *Specification, entries []T) (err error)
- func TrySetupAuditDeletion[T any](ctx context.Context, spec *Specification, entries []T) (err error)
- func TrySetupAuditModification[T any](ctx context.Context, spec *Specification, entries []T) (err error)
- func TrySetupAuditVersion[T any](ctx context.Context, entries []T) (err error)
- func TrySetupLastInsertId[T any](ctx context.Context, entry T, id int64) (v T, err error)
- func WriteInsertReturning[T any](ctx context.Context, rows sql.Rows, returning []string, entries []T) (affected int64, err error)
- type BoolValue
- type ByteValue
- type BytesValue
- type Column
- func (column *Column) Incr() bool
- func (column *Column) Link() (hostField string, awayField string, mapping *Specification, ok bool)
- func (column *Column) Links() (hostField string, awayField string, mapping *Specification, ...)
- func (column *Column) ReadValue(sv reflect.Value) (fv reflect.Value)
- func (column *Column) Reference() (awayField string, mapping *Specification, ok bool)
- func (column *Column) String() (s string)
- func (column *Column) Valid() bool
- func (column *Column) Virtual() (kind VirtualQueryKind, query string, ok bool)
- func (column *Column) WriteValue(field reflect.Value, value any) (err error)
- type ColumnKind
- type ColumnType
- type ColumnTypeName
- type Condition
- type Context
- type DateValue
- type DatetimeValue
- type Dialect
- type Dict
- type FieldValue
- type FloatValue
- type Generic
- type Generics
- type GroupBy
- type IntValue
- type JsonValue
- type MappingValue
- type Method
- func BuildCount[T any](ctx context.Context, cond Condition) (method Method, query []byte, arguments []any, err error)
- func BuildDelete[T any](ctx context.Context, entries []T) (method Method, query []byte, arguments []any, err error)
- func BuildDeleteAnyByCondition(ctx context.Context, entry any, cond Condition) (method Method, query []byte, arguments []any, err error)
- func BuildDeleteByCondition[T any](ctx context.Context, cond Condition) (method Method, query []byte, arguments []any, err error)
- func BuildExist[T any](ctx context.Context, cond Condition) (method Method, query []byte, arguments []any, err error)
- func BuildInsert[T any](ctx context.Context, entries []T) (method Method, query []byte, arguments []any, returning []string, err error)
- func BuildInsertOrUpdate[T any](ctx context.Context, entries []T) (method Method, query []byte, arguments []any, returning []string, err error)
- func BuildInsertWhenExist[T any](ctx context.Context, entries []T, src QueryExpr) (method Method, query []byte, arguments []any, returning []string, err error)
- func BuildInsertWhenNotExist[T any](ctx context.Context, entries []T, src QueryExpr) (method Method, query []byte, arguments []any, returning []string, err error)
- func BuildQuery[T any](ctx context.Context, cond Condition, orders Orders, offset int, length int) (method Method, query []byte, arguments []any, columns []string, err error)
- func BuildUpdate[T any](ctx context.Context, entries []T) (method Method, query []byte, arguments []any, err error)
- func BuildUpdateFields[T any](ctx context.Context, fields []FieldValue, cond Condition) (method Method, query []byte, arguments []any, err error)
- func BuildView[T any](ctx context.Context, cond Condition, orders Orders, groupBy GroupBy, ...) (method Method, query []byte, arguments []any, columns []string, err error)
- type Orders
- type Page
- type Predicate
- type QueryExpr
- type QueryPlaceholder
- type Range
- type Render
- type ScanValue
- type Specification
- func (spec *Specification) ArgumentByField(instance any, field string) (argument any, err error)
- func (spec *Specification) Arguments(instance any, fieldNames []string) (arguments []any, err error)
- func (spec *Specification) AuditCreation() (by *Column, at *Column, has bool)
- func (spec *Specification) AuditDeletion() (by *Column, at *Column, has bool)
- func (spec *Specification) AuditModification() (by *Column, at *Column, has bool)
- func (spec *Specification) AuditVersion() (v *Column, has bool)
- func (spec *Specification) ColumnByField(fieldName string) (column *Column, has bool)
- func (spec *Specification) ConflictColumns() (columns []*Column, err error)
- func (spec *Specification) Instance() (v any)
- func (spec *Specification) Pk() (v *Column, has bool)
- func (spec *Specification) String() (s string)
- type StringValue
- type TableInfo
- type TimeValue
- type ValueWriter
- type ViewInfo
- type VirtualQueryKind
Constants ¶
This section is empty.
Variables ¶
View Source
var ( SELECT = []byte("SELECT") FROM = []byte("FROM") WHERE = []byte("WHERE") INSERT = []byte("INSERT") UPDATE = []byte("UPDATE") DELETE = []byte("DELETE") SPACE = []byte(" ") INTO = []byte("INTO") AND = []byte("AND") SET = []byte("SET") EQ = []byte("=") PLUS = []byte("+") AT = []byte("@") LB = []byte("(") RB = []byte(")") COMMA = []byte(", ") DOT = []byte(".") STAR = []byte("*") AS = []byte("AS") VALUES = []byte("VALUES") EXISTS = []byte("EXISTS") COUNT = []byte("COUNT") NOT = []byte("NOT") CONFLICT = []byte("CONFLICT") ON = []byte("ON") RETURNING = []byte("RETURNING") DO = []byte("DO") NOTHING = []byte("NOTHING") ORDER = []byte("ORDER") BY = []byte("BY") DESC = []byte("DESC") GROUP = []byte("GROUP") HAVING = []byte("HAVING") OFFSET = []byte("OFFSET") LIMIT = []byte("LIMIT") )
Functions ¶
func MaybeTable ¶
func NewBasicValueWriter ¶
func NewBasicValueWriter(rt reflect.Type) (vw ValueWriter, ct ColumnTypeName, err error)
func RegisterDialect ¶
func RegisterDialect(dialect Dialect)
func TrySetupAuditCreation ¶
func TrySetupAuditCreation[T any](ctx context.Context, spec *Specification, entries []T) (err error)
func TrySetupAuditDeletion ¶
func TrySetupAuditDeletion[T any](ctx context.Context, spec *Specification, entries []T) (err error)
func TrySetupAuditModification ¶
func TrySetupAuditModification[T any](ctx context.Context, spec *Specification, entries []T) (err error)
func TrySetupAuditVersion ¶
func TrySetupLastInsertId ¶
Types ¶
type BytesValue ¶
type BytesValue struct {
// contains filtered or unexported fields
}
type Column ¶
type Column struct { FieldIdx []int Field string Name string JsonIdent string Kind ColumnKind Type ColumnType ValueWriter ValueWriter }
Column 'column:"{name},{kind},{options}"'
func (*Column) Link ¶
func (column *Column) Link() (hostField string, awayField string, mapping *Specification, ok bool)
func (*Column) Reference ¶
func (column *Column) Reference() (awayField string, mapping *Specification, ok bool)
type ColumnKind ¶
type ColumnKind int
const ( Normal ColumnKind = iota // column Pk // column,pk{,incr} Acb // column,acb Act // column,act Amb // column,amb Amt // column,amt Adb // column,adb Adt // column,adt Aol // column,aol Json // column,json Virtual // ident,vc,basic|object|array|aggregate,query|agg_func Reference // column,ref,target_field Link // ident,link,field+target_field Links // column,links,field+target_field,orders:field@desc+field,length:10 )
func (ColumnKind) String ¶
func (kind ColumnKind) String() string
type ColumnType ¶
type ColumnType struct { Name ColumnTypeName Value reflect.Type Mapping *Specification Options []string }
func (*ColumnType) String ¶
func (ct *ColumnType) String() string
type ColumnTypeName ¶
type ColumnTypeName int
const ( UnknownType ColumnTypeName = iota StringType BoolType IntType FloatType DatetimeType DateType TimeType BytesType ByteType JsonType ScanType MappingType )
type Condition ¶
type Condition struct {
conditions.Condition
}
type Context ¶
type Context interface { context.Context FormatIdent(ident string) string NextQueryPlaceholder() (v string) SkipNextQueryPlaceholderCursor(n int) // Localization // key can be struct field, struct value and [struct value, struct value] // when field then return column name // when value then return table name // when [struct value, struct value] then return column name of table name Localization(key any) (content []string, has bool) }
type DatetimeValue ¶
type DatetimeValue struct {
// contains filtered or unexported fields
}
type Dialect ¶
type Dialect interface { Name() string FormatIdent(ident string) string QueryPlaceholder() QueryPlaceholder Insert(ctx Context, spec *Specification, values int) (method Method, query []byte, fields []string, returning []string, err error) InsertOrUpdate(ctx Context, spec *Specification) (method Method, query []byte, fields []string, returning []string, err error) InsertWhenExist(ctx Context, spec *Specification, src QueryExpr) (method Method, query []byte, fields []string, arguments []any, returning []string, err error) InsertWhenNotExist(ctx Context, spec *Specification, src QueryExpr) (method Method, query []byte, fields []string, arguments []any, returning []string, err error) Update(ctx Context, spec *Specification) (method Method, query []byte, fields []string, err error) UpdateFields(ctx Context, spec *Specification, fields []FieldValue, cond Condition) (method Method, query []byte, arguments []any, err error) Delete(ctx Context, spec *Specification) (method Method, query []byte, fields []string, err error) DeleteByConditions(ctx Context, spec *Specification, cond Condition) (method Method, query []byte, audits []string, arguments []any, err error) Exist(ctx Context, spec *Specification, cond Condition) (method Method, query []byte, arguments []any, err error) Count(ctx Context, spec *Specification, cond Condition) (method Method, query []byte, arguments []any, err error) Query(ctx Context, spec *Specification, cond Condition, orders Orders, offset int, length int) (method Method, query []byte, arguments []any, fields []string, err error) View(ctx Context, spec *Specification, cond Condition, orders Orders, groupBy GroupBy, offset int, length int) (method Method, query []byte, arguments []any, fields []string, err error) }
type FieldValue ¶
type FloatValue ¶
type FloatValue struct {
// contains filtered or unexported fields
}
type MappingValue ¶
type Method ¶
type Method int
func BuildCount ¶
func BuildDelete ¶
func BuildDeleteByCondition ¶
func BuildExist ¶
func BuildInsert ¶
func BuildInsertOrUpdate ¶
func BuildInsertWhenExist ¶
func BuildInsertWhenNotExist ¶
func BuildQuery ¶
func BuildUpdate ¶
func BuildUpdateFields ¶
type Predicate ¶
type Predicate struct {
conditions.Predicate
}
type QueryExpr ¶
type QueryExpr struct {
conditions.QueryExpr
}
type QueryPlaceholder ¶
type Specification ¶
type Specification struct { Key string Schema string Name string View bool ViewBase *Specification Type reflect.Type Columns []*Column Conflicts []string }
func GetSpecification ¶
func GetSpecification(ctx context.Context, e any) (spec *Specification, err error)
func (*Specification) ArgumentByField ¶
func (spec *Specification) ArgumentByField(instance any, field string) (argument any, err error)
func (*Specification) Arguments ¶
func (spec *Specification) Arguments(instance any, fieldNames []string) (arguments []any, err error)
func (*Specification) AuditCreation ¶
func (spec *Specification) AuditCreation() (by *Column, at *Column, has bool)
func (*Specification) AuditDeletion ¶
func (spec *Specification) AuditDeletion() (by *Column, at *Column, has bool)
func (*Specification) AuditModification ¶
func (spec *Specification) AuditModification() (by *Column, at *Column, has bool)
func (*Specification) AuditVersion ¶
func (spec *Specification) AuditVersion() (v *Column, has bool)
func (*Specification) ColumnByField ¶
func (spec *Specification) ColumnByField(fieldName string) (column *Column, has bool)
func (*Specification) ConflictColumns ¶
func (spec *Specification) ConflictColumns() (columns []*Column, err error)
func (*Specification) Instance ¶
func (spec *Specification) Instance() (v any)
func (*Specification) Pk ¶
func (spec *Specification) Pk() (v *Column, has bool)
func (*Specification) String ¶
func (spec *Specification) String() (s string)
type StringValue ¶
type StringValue struct {
// contains filtered or unexported fields
}
type TableInfo ¶
type TableInfo struct {
// contains filtered or unexported fields
}
func GetTableInfo ¶
type ViewInfo ¶
type ViewInfo struct {
// contains filtered or unexported fields
}
func GetViewInfo ¶
type VirtualQueryKind ¶
type VirtualQueryKind int
const ( UnknownVirtualQueryKind VirtualQueryKind = iota BasicVirtualQuery ObjectVirtualQuery ArrayVirtualQuery AggregateVirtualQuery )
Click to show internal directories.
Click to hide internal directories.