Documentation
¶
Index ¶
- Constants
- func RegisterDialect(name string)
- func Service() fns.Service
- func TxBegin(ctx fns.Context, param TxBeginParam) (err errors.CodeError)
- func TxCommit(ctx fns.Context) (err errors.CodeError)
- func TxRollback(ctx fns.Context) (err errors.CodeError)
- type Client
- type Cluster
- type Column
- type ColumnType
- type Config
- type DAOConfig
- type DaoCache
- type DatabaseAccessObject
- type ExecResult
- type Executor
- type FieldColumn
- type GlobalTransaction
- type GlobalTransactionManagement
- func (gtm *GlobalTransactionManagement) Begin(ctx fns.Context, db0 *db.DB, isolation db.IsolationLevel, ...) (err error)
- func (gtm *GlobalTransactionManagement) Close()
- func (gtm *GlobalTransactionManagement) Commit(ctx fns.Context) (err error)
- func (gtm *GlobalTransactionManagement) GetTx(ctx fns.Context) (tx *db.Tx, has bool)
- func (gtm *GlobalTransactionManagement) Rollback(ctx fns.Context)
- type KDB
- type MasterSlaver
- type NullJson
- type NullSQLRaw
- type Paged
- type Param
- type QueryAble
- type QueryCondition
- type QueryConditions
- func (c *QueryConditions) Between(column string, beg interface{}, end interface{}) *QueryConditions
- func (c *QueryConditions) Eq(column string, value interface{}) *QueryConditions
- func (c *QueryConditions) GT(column string, value interface{}) *QueryConditions
- func (c *QueryConditions) GTE(column string, value interface{}) *QueryConditions
- func (c *QueryConditions) In(column string, values ...interface{}) *QueryConditions
- func (c *QueryConditions) LT(column string, value interface{}) *QueryConditions
- func (c *QueryConditions) LTE(column string, value interface{}) *QueryConditions
- func (c *QueryConditions) Like(column string, value interface{}) *QueryConditions
- func (c *QueryConditions) NotEq(column string, value interface{}) *QueryConditions
- type QueryParam
- type QuerySort
- type Row
- type Rows
- type Standalone
- type TableRow
- type Tuple
- type TxAddress
- type TxBeginParam
Constants ¶
View Source
const ( StringType = ColumnType("string") IntType = ColumnType("int") FloatType = ColumnType("float") BytesType = ColumnType("bytes") JsonType = ColumnType("json") BoolType = ColumnType("bool") TimeType = ColumnType("time") UnknownType = ColumnType("unknown") )
View Source
const ( Namespace = "sql" TxBeginFn = "tx_begin" TxCommitFn = "tx_commit" TxRollbackFn = "tx_rollback" QueryFn = "query" ExecuteFn = "execute" )
Variables ¶
This section is empty.
Functions ¶
func RegisterDialect ¶ added in v0.6.0
func RegisterDialect(name string)
Types ¶
type Column ¶
type Column struct {
Type ColumnType `json:"type,omitempty"`
Name string `json:"name,omitempty"`
Value json.RawMessage `json:"value,omitempty"`
Nil bool `json:"nil,omitempty"`
// contains filtered or unexported fields
}
type ColumnType ¶
type ColumnType string
type Config ¶
type Config struct {
Driver string `json:"driver"`
MasterSlaverMode bool `json:"masterSlaverMode,omitempty"`
DSN []string `json:"dsn,omitempty"`
MaxIdles int `json:"maxIdles,omitempty"`
MaxOpens int `json:"maxOpens,omitempty"`
EnableDebugLog bool `json:"enableDebugLog"`
DAO DAOConfig `json:"dao,omitempty"`
}
func (*Config) CreateClient ¶
type DAOConfig ¶ added in v0.6.0
type DAOConfig struct {
CacheKind string `json:"cacheKind,omitempty"`
Raw json.RawMessage `json:"options,omitempty"`
}
type DatabaseAccessObject ¶ added in v0.6.0
type DatabaseAccessObject interface {
Save(ctx fns.Context, rows ...TableRow) (affected int, err errors.CodeError)
Insert(ctx fns.Context, rows ...TableRow) (affected int, err errors.CodeError)
Update(ctx fns.Context, rows ...TableRow) (affected int, err errors.CodeError)
Delete(ctx fns.Context, rows ...TableRow) (affected int, err errors.CodeError)
Exist(ctx fns.Context, row TableRow) (has bool, err errors.CodeError)
Get(ctx fns.Context, row TableRow) (has bool, err errors.CodeError)
Query(ctx fns.Context, param *QueryParam, rows interface{}) (has bool, err errors.CodeError)
Count(ctx fns.Context, param *QueryParam, row TableRow) (num int, err errors.CodeError)
Page(ctx fns.Context, param *QueryParam, rows interface{}) (page Paged, err errors.CodeError)
Close()
}
func DAO ¶ added in v0.6.0
func DAO(ctx fns.Context) (v DatabaseAccessObject)
type ExecResult ¶
type FieldColumn ¶ added in v0.3.10
type GlobalTransaction ¶
type GlobalTransaction struct {
// contains filtered or unexported fields
}
type GlobalTransactionManagement ¶
type GlobalTransactionManagement struct {
// contains filtered or unexported fields
}
func NewGlobalTransactionManagement ¶
func NewGlobalTransactionManagement() *GlobalTransactionManagement
func (*GlobalTransactionManagement) Begin ¶ added in v0.4.2
func (gtm *GlobalTransactionManagement) Begin(ctx fns.Context, db0 *db.DB, isolation db.IsolationLevel, timeout time.Duration) (err error)
func (*GlobalTransactionManagement) Close ¶
func (gtm *GlobalTransactionManagement) Close()
func (*GlobalTransactionManagement) Commit ¶ added in v0.4.2
func (gtm *GlobalTransactionManagement) Commit(ctx fns.Context) (err error)
func (*GlobalTransactionManagement) Rollback ¶ added in v0.4.2
func (gtm *GlobalTransactionManagement) Rollback(ctx fns.Context)
type MasterSlaver ¶
type MasterSlaver struct {
// contains filtered or unexported fields
}
func NewMasterSlaver ¶
func NewMasterSlaver(master *db.DB, slavers []*db.DB) (client *MasterSlaver)
func (*MasterSlaver) Close ¶
func (client *MasterSlaver) Close() (err error)
func (*MasterSlaver) Reader ¶
func (client *MasterSlaver) Reader() (v *db.DB)
func (*MasterSlaver) Writer ¶
func (client *MasterSlaver) Writer() (v *db.DB)
type NullJson ¶
type NullJson struct {
Json json.RawMessage
Valid bool
}
type NullSQLRaw ¶
func (*NullSQLRaw) Scan ¶
func (v *NullSQLRaw) Scan(src interface{}) error
type QueryCondition ¶ added in v0.6.0
type QueryCondition struct {
// contains filtered or unexported fields
}
type QueryConditions ¶ added in v0.6.0
type QueryConditions struct {
// contains filtered or unexported fields
}
func NewQueryConditions ¶ added in v0.6.0
func NewQueryConditions() *QueryConditions
func (*QueryConditions) Between ¶ added in v0.6.0
func (c *QueryConditions) Between(column string, beg interface{}, end interface{}) *QueryConditions
func (*QueryConditions) Eq ¶ added in v0.6.0
func (c *QueryConditions) Eq(column string, value interface{}) *QueryConditions
func (*QueryConditions) GT ¶ added in v0.6.0
func (c *QueryConditions) GT(column string, value interface{}) *QueryConditions
func (*QueryConditions) GTE ¶ added in v0.6.0
func (c *QueryConditions) GTE(column string, value interface{}) *QueryConditions
func (*QueryConditions) In ¶ added in v0.6.0
func (c *QueryConditions) In(column string, values ...interface{}) *QueryConditions
func (*QueryConditions) LT ¶ added in v0.6.0
func (c *QueryConditions) LT(column string, value interface{}) *QueryConditions
func (*QueryConditions) LTE ¶ added in v0.6.0
func (c *QueryConditions) LTE(column string, value interface{}) *QueryConditions
func (*QueryConditions) Like ¶ added in v0.6.0
func (c *QueryConditions) Like(column string, value interface{}) *QueryConditions
func (*QueryConditions) NotEq ¶ added in v0.6.0
func (c *QueryConditions) NotEq(column string, value interface{}) *QueryConditions
type QueryParam ¶ added in v0.6.0
type QueryParam struct {
// contains filtered or unexported fields
}
func NewQueryParam ¶ added in v0.6.0
func NewQueryParam() *QueryParam
func (*QueryParam) ASC ¶ added in v0.6.0
func (p *QueryParam) ASC(column string) *QueryParam
func (*QueryParam) Conditions ¶ added in v0.6.0
func (p *QueryParam) Conditions() *QueryConditions
func (*QueryParam) DESC ¶ added in v0.6.0
func (p *QueryParam) DESC(column string) *QueryParam
func (*QueryParam) Page ¶ added in v0.6.0
func (p *QueryParam) Page(no int, size int) *QueryParam
func (*QueryParam) Range ¶ added in v0.6.0
func (p *QueryParam) Range(offset int, length int) *QueryParam
type QuerySort ¶ added in v0.6.0
type QuerySort struct {
// contains filtered or unexported fields
}
type Standalone ¶
type Standalone struct {
// contains filtered or unexported fields
}
func NewStandalone ¶
func NewStandalone(v *db.DB) (client *Standalone)
func (*Standalone) Close ¶
func (client *Standalone) Close() (err error)
func (*Standalone) Reader ¶
func (client *Standalone) Reader() (v *db.DB)
func (*Standalone) Writer ¶
func (client *Standalone) Writer() (v *db.DB)
type Tuple ¶
type Tuple struct {
// contains filtered or unexported fields
}
func (Tuple) MarshalJSON ¶
func (*Tuple) UnmarshalJSON ¶
type TxBeginParam ¶
type TxBeginParam struct {
Timeout time.Duration `json:"timeout,omitempty"`
Isolation db.IsolationLevel `json:"isolation,omitempty"`
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.