Documentation ¶
Index ¶
- Constants
- Variables
- func RegisterProvider(name string, builder ProviderBuilder)
- func RegisterType(i interface{}, options *TableOptions)
- func Use(fs ...Filter)
- func UseDB(db string, fs ...Filter)
- type AndCriteriaSet
- type Builder
- type CallInfo
- type Column
- type ColumnFilter
- type ColumnOptions
- type Columns
- type CountClause
- type CountGroupByClause
- type CountResultClause
- type CountWhereClause
- type Criteria
- type CriteriaSet
- type DB
- type DecValue
- type DeleteClause
- type DeleteInfo
- type ExecuteClause
- type ExecuteInfo
- type ExecuteResult
- type Executor
- type ExprColumn
- type ExprCriteria
- type ExprValue
- type Factory
- type Filter
- type Filters
- type FromClause
- type GroupByClause
- type HavingClause
- type IncValue
- type InsertClause
- type InsertColumnsClause
- type InsertInfo
- type InsertResult
- type InsertResultClause
- type InsertValuesClause
- type JoinClause
- type JoinCriteriaSet
- type LazyDB
- type LimitClause
- type Meta
- func (m *Meta) CopyInsertValues(i interface{}, values []interface{})
- func (m *Meta) CopyPrimaryKeyValues(i interface{}, values []interface{})
- func (m *Meta) CopyUpdateValues(i interface{}, values []interface{})
- func (m *Meta) CopyValues(i interface{}, values []interface{}, cols ...string)
- func (m *Meta) InsertValues(i interface{}) []interface{}
- func (m *Meta) Pointers(i interface{}, cols ...string) []interface{}
- func (m *Meta) PrimaryKeyValues(i interface{}) []interface{}
- func (m *Meta) SetAutoValue(i interface{}, value int64)
- func (m *Meta) SetValue(i interface{}, col string, val interface{})
- func (m *Meta) UpdateValues(i interface{}) []interface{}
- func (m *Meta) Value(i interface{}, col string) interface{}
- func (m *Meta) Values(i interface{}, cols ...string) []interface{}
- func (m *Meta) WhereValues(i interface{}) CriteriaSet
- type MetaFactory
- type NotCriteriaSet
- type NullFloat32
- type NullInt32
- type NullTime
- type OneColumnCriteria
- type Options
- type OrCriteriaSet
- type Order
- type OrderByClause
- type OrderType
- type Provider
- type ProviderBuilder
- type Reader
- type Result
- type ResultClause
- type SelectClause
- type SelectInfo
- type SelectResultClause
- type SetClause
- type SimpleColumn
- type SimpleCriteriaSet
- func (c *SimpleCriteriaSet) Between(col, start, end interface{}) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) Contains(col interface{}, s string) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) Date(col interface{}, date time.Time) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) DateRange(col interface{}, start, end time.Time) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) Empty() bool
- func (c *SimpleCriteriaSet) Equal(col, val interface{}) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) Equal2(left, right interface{}) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) EqualIf(when bool, col, val interface{}) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) Greater(col, val interface{}) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) Greater2(left, right interface{}) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) GreaterIf(when bool, col, val interface{}) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) GreaterOrEqual(col, val interface{}) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) GreaterOrEqual2(left, right interface{}) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) GreaterOrEqualIf(when bool, col, val interface{}) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) In(col, val interface{}) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) InIf(when bool, col, val interface{}) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) Less(col, val interface{}) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) Less2(left, right interface{}) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) LessIf(when bool, col, val interface{}) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) LessOrEqual(col, val interface{}) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) LessOrEqual2(left, right interface{}) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) LessOrEqualIf(when bool, col, val interface{}) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) Like(col interface{}, expr string) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) LikeIf(when bool, col interface{}, expr string) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) NotEqual(col, val interface{}) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) NotEqual2(left, right interface{}) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) NotEqualIf(when bool, col, val interface{}) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) NotIn(col, val interface{}) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) NotInIf(when bool, col, val interface{}) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) Prefix(col interface{}, s string) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) Suffix(col interface{}, s string) *SimpleCriteriaSet
- func (c *SimpleCriteriaSet) Wild(expr string) *SimpleCriteriaSet
- type Stmt
- type TX
- type Table
- type TableColumn
- type TableOptions
- type TwoColumnCriteria
- type UpdateClause
- type UpdateInfo
- type Value
- type WhereClause
Constants ¶
View Source
const ( EQ = iota NE LT LTE GT GTE IN NIN LK )
View Source
const PkgName = "auxo.db.gsd"
Variables ¶
View Source
var ( DefaultTableOptions = &TableOptions{ NameStyle: texts.Lower, ColumnNameStyle: texts.Lower, } )
View Source
var (
ErrNoRows = sql.ErrNoRows
)
View Source
var ErrTXCancelled = errors.New("gsd: transaction has been cancelled")
Functions ¶
func RegisterProvider ¶
func RegisterProvider(name string, builder ProviderBuilder)
func RegisterType ¶
func RegisterType(i interface{}, options *TableOptions)
Types ¶
type AndCriteriaSet ¶
type AndCriteriaSet struct {
// contains filtered or unexported fields
}
func (*AndCriteriaSet) Empty ¶
func (c *AndCriteriaSet) Empty() bool
func (*AndCriteriaSet) Joiner ¶
func (c *AndCriteriaSet) Joiner() string
func (*AndCriteriaSet) Left ¶
func (c *AndCriteriaSet) Left() CriteriaSet
func (*AndCriteriaSet) Right ¶
func (c *AndCriteriaSet) Right() CriteriaSet
type ColumnFilter ¶
func Include ¶
func Include(cols ...string) ColumnFilter
func Omit ¶
func Omit(cols ...string) ColumnFilter
type ColumnOptions ¶
type ColumnOptions struct { Name string `json:"name"` AutoIncrement bool `json:"auto"` PrimaryKey bool `json:"pk"` ForeignKey bool `json:"fk"` Insert bool `json:"insert"` Update bool `json:"update"` Select bool `json:"select"` Where *struct { Column string Type int Index int } Size int `json:"size"` }
ColumnOptions is table column options
type CountClause ¶
type CountClause interface { Join(table interface{}, on CriteriaSet) CountClause LeftJoin(t interface{}, on CriteriaSet) CountClause RightJoin(t interface{}, on CriteriaSet) CountClause FullJoin(t interface{}, on CriteriaSet) CountClause Where(f CriteriaSet) CountWhereClause CountResultClause }
type CountGroupByClause ¶
type CountGroupByClause interface { Having(f CriteriaSet) CountResultClause CountResultClause }
type CountResultClause ¶
type CountWhereClause ¶
type CountWhereClause interface { GroupBy(cols *Columns) CountGroupByClause CountResultClause }
type CriteriaSet ¶
type CriteriaSet interface {
Empty() bool
}
func And ¶
func And(left, right CriteriaSet) CriteriaSet
func Not ¶
func Not(inner CriteriaSet) CriteriaSet
func Or ¶
func Or(left, right CriteriaSet) CriteriaSet
type DB ¶
type DB interface { Insert(ctx context.Context, table string) InsertClause Create(ctx context.Context, i interface{}, filter ...ColumnFilter) error Delete(ctx context.Context, table string) DeleteClause Remove(ctx context.Context, i interface{}) (r Result, err error) Update(ctx context.Context, table string) UpdateClause Modify(ctx context.Context, i interface{}, filter ...ColumnFilter) (r Result, err error) Select(ctx context.Context, cols ...string) SelectClause //Distinct(ctx context.Context, cols ...string) SelectClause Query(ctx context.Context, cols *Columns, distinct ...bool) SelectClause Load(ctx context.Context, i interface{}) error Count(ctx context.Context, table interface{}) CountClause Execute(ctx context.Context, sql string, args ...interface{}) ExecuteClause //Call(ctx context.Context, sp string, args ...interface{}) CallClause Prepare(ctx context.Context, query string) (*Stmt, error) Stmt(name string, b func() string) (*Stmt, error) Transact(ctx context.Context, fn func(tx TX) error, opts ...*sql.TxOptions) (err error) }
type DeleteClause ¶
type DeleteClause interface {
Where(f CriteriaSet) ResultClause
}
type DeleteInfo ¶
type DeleteInfo struct { Table string Where CriteriaSet }
type ExecuteClause ¶
type ExecuteInfo ¶
type ExecuteInfo struct {
// contains filtered or unexported fields
}
type ExecuteResult ¶
type ExprColumn ¶
type ExprColumn struct {
// contains filtered or unexported fields
}
func (*ExprColumn) Alias ¶
func (c *ExprColumn) Alias() string
func (*ExprColumn) Field ¶
func (c *ExprColumn) Field() string
func (*ExprColumn) Name ¶
func (c *ExprColumn) Name() string
func (*ExprColumn) Table ¶
func (c *ExprColumn) Table() Table
type ExprCriteria ¶
type ExprCriteria string
type FromClause ¶
type FromClause interface { LimitClause SelectResultClause Join(table interface{}, on CriteriaSet) JoinClause LeftJoin(t interface{}, on CriteriaSet) JoinClause RightJoin(t interface{}, on CriteriaSet) JoinClause FullJoin(t interface{}, on CriteriaSet) JoinClause Where(f CriteriaSet) WhereClause }
type GroupByClause ¶
type GroupByClause interface { LimitClause OrderBy(orders ...*Order) OrderByClause Having(f CriteriaSet) HavingClause SelectResultClause }
type HavingClause ¶
type HavingClause interface { LimitClause SelectResultClause OrderBy(orders ...*Order) OrderByClause }
type InsertClause ¶
type InsertClause interface {
Columns(cols ...string) InsertColumnsClause
}
type InsertColumnsClause ¶
type InsertColumnsClause interface {
Values(values ...interface{}) InsertValuesClause
}
type InsertInfo ¶
type InsertInfo struct { Table string Columns []string Values []interface{} // single row or multiple rows Filter ColumnFilter }
type InsertResult ¶
type InsertResultClause ¶
type InsertResultClause interface { Submit() error Result() (InsertResult, error) }
type InsertValuesClause ¶
type InsertValuesClause interface { Values(values ...interface{}) InsertValuesClause InsertResultClause }
type JoinClause ¶
type JoinClause interface { FromClause }
type JoinCriteriaSet ¶
type JoinCriteriaSet interface { CriteriaSet Left() CriteriaSet Right() CriteriaSet Joiner() string }
type LimitClause ¶
type LimitClause interface { //Lock(Exclusive/Shared) SelectResultClause Limit(skip, take int) SelectResultClause Page(index, size int) SelectResultClause }
type Meta ¶
type Meta struct { ID int32 Table string Auto string // auto increment column PrimaryKeys []string // primary key columns //ForeignKeys []string // foreign key columns Updates []string // update columns Inserts []string // insert columns Selects []string // select columns Columns []string // all columns, columns = keys + updates = autos + inserts Wheres []*struct { Column string Type int Index int } // contains filtered or unexported fields }
func (*Meta) CopyInsertValues ¶
func (m *Meta) CopyInsertValues(i interface{}, values []interface{})
CopyInsertValues copy values of insert-fields to struct i
func (*Meta) CopyPrimaryKeyValues ¶
func (m *Meta) CopyPrimaryKeyValues(i interface{}, values []interface{})
CopyPrimaryKeyValues copy values of pk-fields to struct i
func (*Meta) CopyUpdateValues ¶
func (m *Meta) CopyUpdateValues(i interface{}, values []interface{})
CopyUpdateValues copy values of update-fields to struct i
func (*Meta) CopyValues ¶
CopyValues copy fields to struct i
func (*Meta) InsertValues ¶
func (m *Meta) InsertValues(i interface{}) []interface{}
InsertValues return values of insert-fields
func (*Meta) PrimaryKeyValues ¶
func (m *Meta) PrimaryKeyValues(i interface{}) []interface{}
PrimaryKeyValues return values of key-fields
func (*Meta) SetAutoValue ¶
SetAutoValue set value of auto increment field
func (*Meta) UpdateValues ¶
func (m *Meta) UpdateValues(i interface{}) []interface{}
UpdateValues return values of update-fields
func (*Meta) WhereValues ¶
func (m *Meta) WhereValues(i interface{}) CriteriaSet
WhereValues return values of searching criteria set.
type MetaFactory ¶
type MetaFactory struct {
// contains filtered or unexported fields
}
type NotCriteriaSet ¶
type NotCriteriaSet struct {
Inner CriteriaSet
}
func (*NotCriteriaSet) Empty ¶
func (c *NotCriteriaSet) Empty() bool
type NullFloat32 ¶
func (*NullFloat32) Scan ¶
func (n *NullFloat32) Scan(value interface{}) (err error)
Scan implements the Scanner interface.
type NullTime ¶
NullTime is a nullable NullTime value
type OneColumnCriteria ¶
type OrCriteriaSet ¶
type OrCriteriaSet struct {
// contains filtered or unexported fields
}
func (*OrCriteriaSet) Empty ¶
func (c *OrCriteriaSet) Empty() bool
func (*OrCriteriaSet) Joiner ¶
func (c *OrCriteriaSet) Joiner() string
func (*OrCriteriaSet) Left ¶
func (c *OrCriteriaSet) Left() CriteriaSet
func (*OrCriteriaSet) Right ¶
func (c *OrCriteriaSet) Right() CriteriaSet
type OrderByClause ¶
type OrderByClause interface { LimitClause SelectResultClause }
type Provider ¶
type Provider interface { BuildInsert(b *Builder, ctx *InsertInfo) (err error) BuildDelete(b *Builder, ctx *DeleteInfo) (err error) BuildUpdate(b *Builder, ctx *UpdateInfo) (err error) BuildSelect(b *Builder, ctx *SelectInfo) (err error) BuildCall(b *Builder, ctx *CallInfo) (err error) }
type ProviderBuilder ¶
type ResultClause ¶
type SelectClause ¶
type SelectClause interface {
From(table interface{}) FromClause
}
type SelectInfo ¶
type SelectInfo struct { Table Distinct bool Columns Where CriteriaSet Joins []struct { Type string Table On CriteriaSet } Groups Columns Having CriteriaSet Orders []*Order Skip int Take int Count bool // return total count }
type SelectResultClause ¶
type SetClause ¶
type SetClause interface { UpdateClause ResultClause Where(f CriteriaSet) ResultClause }
type SimpleColumn ¶
type SimpleColumn string
func (SimpleColumn) Alias ¶
func (c SimpleColumn) Alias() string
func (SimpleColumn) Field ¶
func (c SimpleColumn) Field() string
func (SimpleColumn) Name ¶
func (c SimpleColumn) Name() string
func (SimpleColumn) Table ¶
func (SimpleColumn) Table() Table
type SimpleCriteriaSet ¶
type SimpleCriteriaSet struct {
Items []Criteria
}
func Equal ¶
func Equal(col, val interface{}) *SimpleCriteriaSet
func (*SimpleCriteriaSet) Between ¶
func (c *SimpleCriteriaSet) Between(col, start, end interface{}) *SimpleCriteriaSet
func (*SimpleCriteriaSet) Contains ¶
func (c *SimpleCriteriaSet) Contains(col interface{}, s string) *SimpleCriteriaSet
func (*SimpleCriteriaSet) Date ¶
func (c *SimpleCriteriaSet) Date(col interface{}, date time.Time) *SimpleCriteriaSet
func (*SimpleCriteriaSet) DateRange ¶
func (c *SimpleCriteriaSet) DateRange(col interface{}, start, end time.Time) *SimpleCriteriaSet
func (*SimpleCriteriaSet) Empty ¶
func (c *SimpleCriteriaSet) Empty() bool
func (*SimpleCriteriaSet) Equal ¶
func (c *SimpleCriteriaSet) Equal(col, val interface{}) *SimpleCriteriaSet
func (*SimpleCriteriaSet) Equal2 ¶
func (c *SimpleCriteriaSet) Equal2(left, right interface{}) *SimpleCriteriaSet
func (*SimpleCriteriaSet) EqualIf ¶
func (c *SimpleCriteriaSet) EqualIf(when bool, col, val interface{}) *SimpleCriteriaSet
func (*SimpleCriteriaSet) Greater ¶
func (c *SimpleCriteriaSet) Greater(col, val interface{}) *SimpleCriteriaSet
func (*SimpleCriteriaSet) Greater2 ¶
func (c *SimpleCriteriaSet) Greater2(left, right interface{}) *SimpleCriteriaSet
func (*SimpleCriteriaSet) GreaterIf ¶
func (c *SimpleCriteriaSet) GreaterIf(when bool, col, val interface{}) *SimpleCriteriaSet
func (*SimpleCriteriaSet) GreaterOrEqual ¶
func (c *SimpleCriteriaSet) GreaterOrEqual(col, val interface{}) *SimpleCriteriaSet
func (*SimpleCriteriaSet) GreaterOrEqual2 ¶
func (c *SimpleCriteriaSet) GreaterOrEqual2(left, right interface{}) *SimpleCriteriaSet
func (*SimpleCriteriaSet) GreaterOrEqualIf ¶
func (c *SimpleCriteriaSet) GreaterOrEqualIf(when bool, col, val interface{}) *SimpleCriteriaSet
func (*SimpleCriteriaSet) In ¶
func (c *SimpleCriteriaSet) In(col, val interface{}) *SimpleCriteriaSet
func (*SimpleCriteriaSet) InIf ¶
func (c *SimpleCriteriaSet) InIf(when bool, col, val interface{}) *SimpleCriteriaSet
func (*SimpleCriteriaSet) Less ¶
func (c *SimpleCriteriaSet) Less(col, val interface{}) *SimpleCriteriaSet
func (*SimpleCriteriaSet) Less2 ¶
func (c *SimpleCriteriaSet) Less2(left, right interface{}) *SimpleCriteriaSet
func (*SimpleCriteriaSet) LessIf ¶
func (c *SimpleCriteriaSet) LessIf(when bool, col, val interface{}) *SimpleCriteriaSet
func (*SimpleCriteriaSet) LessOrEqual ¶
func (c *SimpleCriteriaSet) LessOrEqual(col, val interface{}) *SimpleCriteriaSet
func (*SimpleCriteriaSet) LessOrEqual2 ¶
func (c *SimpleCriteriaSet) LessOrEqual2(left, right interface{}) *SimpleCriteriaSet
func (*SimpleCriteriaSet) LessOrEqualIf ¶
func (c *SimpleCriteriaSet) LessOrEqualIf(when bool, col, val interface{}) *SimpleCriteriaSet
func (*SimpleCriteriaSet) Like ¶
func (c *SimpleCriteriaSet) Like(col interface{}, expr string) *SimpleCriteriaSet
Like add a LIKE criteria
c.Like("name", "%abc") c.Like("name", "abc_")
func (*SimpleCriteriaSet) LikeIf ¶
func (c *SimpleCriteriaSet) LikeIf(when bool, col interface{}, expr string) *SimpleCriteriaSet
func (*SimpleCriteriaSet) NotEqual ¶
func (c *SimpleCriteriaSet) NotEqual(col, val interface{}) *SimpleCriteriaSet
func (*SimpleCriteriaSet) NotEqual2 ¶
func (c *SimpleCriteriaSet) NotEqual2(left, right interface{}) *SimpleCriteriaSet
func (*SimpleCriteriaSet) NotEqualIf ¶
func (c *SimpleCriteriaSet) NotEqualIf(when bool, col, val interface{}) *SimpleCriteriaSet
func (*SimpleCriteriaSet) NotIn ¶
func (c *SimpleCriteriaSet) NotIn(col, val interface{}) *SimpleCriteriaSet
func (*SimpleCriteriaSet) NotInIf ¶
func (c *SimpleCriteriaSet) NotInIf(when bool, col, val interface{}) *SimpleCriteriaSet
func (*SimpleCriteriaSet) Prefix ¶
func (c *SimpleCriteriaSet) Prefix(col interface{}, s string) *SimpleCriteriaSet
func (*SimpleCriteriaSet) Suffix ¶
func (c *SimpleCriteriaSet) Suffix(col interface{}, s string) *SimpleCriteriaSet
func (*SimpleCriteriaSet) Wild ¶
func (c *SimpleCriteriaSet) Wild(expr string) *SimpleCriteriaSet
Wild add a custom expression criteria
f.Wild("a > (b + 100)")
type TX ¶
type TX interface { Insert(ctx context.Context, table string) InsertClause Create(ctx context.Context, i interface{}, filter ...ColumnFilter) error Delete(ctx context.Context, table string) DeleteClause Remove(ctx context.Context, i interface{}) (r Result, err error) Update(ctx context.Context, table string) UpdateClause Modify(ctx context.Context, i interface{}, filter ...ColumnFilter) (r Result, err error) Select(ctx context.Context, cols ...string) SelectClause Query(ctx context.Context, cols *Columns, distinct ...bool) SelectClause Load(ctx context.Context, i interface{}) error Count(ctx context.Context, table interface{}) CountClause Execute(ctx context.Context, sql string, args ...interface{}) ExecuteClause Prepare(ctx context.Context, query string) (*Stmt, error) Stmt(name string, b func() string) (*Stmt, error) Commit() error Rollback() error }
type TableColumn ¶
type TableColumn struct {
// contains filtered or unexported fields
}
func (*TableColumn) Alias ¶
func (c *TableColumn) Alias() string
func (*TableColumn) Field ¶
func (c *TableColumn) Field() string
func (*TableColumn) Name ¶
func (c *TableColumn) Name() string
func (*TableColumn) Table ¶
func (c *TableColumn) Table() Table
type TableOptions ¶
type TwoColumnCriteria ¶
type UpdateClause ¶
type UpdateInfo ¶
type UpdateInfo struct { Table string Columns []string Values []interface{} Where CriteriaSet Filter ColumnFilter }
type WhereClause ¶
type WhereClause interface { LimitClause //One(i interface{}) error SelectResultClause GroupBy(cols *Columns) GroupByClause OrderBy(orders ...*Order) OrderByClause }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.