Documentation
¶
Index ¶
- Constants
- Variables
- func MaxIdle(count int) mist.Option
- func MaxOpen(count int) mist.Option
- func MysqlAddress(name, read, write string) mist.Option
- func PgAddress(name, read, write string) mist.Option
- func Scan(rows *sql.Rows, db *DB)
- type Builder
- type Clause
- type ConnPool
- type DB
- func (db *DB) AddError(err error) error
- func (db *DB) AddNameMap(old, new string) (tx *DB)
- func (db *DB) Begin(opts ...*sql.TxOptions) *DB
- func (db *DB) Commit() *DB
- func (db *DB) Exec(sql string, args ...interface{}) (tx *DB)
- func (db *DB) Find(dest interface{}) (tx *DB)
- func (db *DB) GroupBy(column string) (tx *DB)
- func (m *DB) ID() string
- func (db *DB) Limit(limit int) (tx *DB)
- func (db *DB) Listen(ctx context.Context, channel string) (abstract.Observable, error)
- func (db *DB) MustWrite() (tx *DB)
- func (db *DB) Offset(offset int) (tx *DB)
- func (db *DB) Order(value interface{}) (tx *DB)
- func (db *DB) Paging(page, perPage int) (tx *DB)
- func (db *DB) Query(sql string, args ...interface{}) (tx *DB)
- func (db *DB) QueryReturn(sql string, args ...interface{}) (tx *DB)
- func (db *DB) Reset() (tx *DB)
- func (db *DB) Rollback() *DB
- func (db *DB) Rows() []*DataRow
- func (m *DB) TypeName() string
- func (db *DB) Where(where ...interface{}) (tx *DB)
- type DataRow
- func (d *DataRow) GetFloat64(fieldName string) float64
- func (d *DataRow) GetInt(fieldName string) int
- func (d *DataRow) GetInt32(fieldName string) int32
- func (d *DataRow) GetInt64(fieldName string) int64
- func (d *DataRow) GetString(fieldName string) string
- func (d *DataRow) GetTime(fieldName string) time.Time
- func (d *DataRow) GetTimeStr(fieldName string) string
- type Expression
- type IClause
- type Limit
- type Middleware
- type Statement
- func (st *Statement) AddClause(v IClause)
- func (st *Statement) AddVar(vars ...interface{})
- func (st *Statement) Build(clauses ...string)
- func (st *Statement) Parse(value interface{}) (err error)
- func (st *Statement) Reset() (tx *DB)
- func (st *Statement) WriteByte(c byte) error
- func (st *Statement) WriteQuoted(value interface{})
- func (st *Statement) WriteString(str string) (int, error)
- type TxBeginner
- type TxCommitter
- type Where
- func (where *Where) And(field string, quality WhereEquality, value interface{}) WhereColumn
- func (where Where) Build(builder Builder)
- func (where Where) MergeClause(clause *Clause)
- func (where Where) Name() string
- func (where *Where) Or(field string, quality WhereEquality, value interface{}) WhereColumn
- type WhereColumn
- type WhereEquality
- type Writer
Constants ¶
View Source
const MiddlewareName = "zsql"
Variables ¶
View Source
var ( ErrInvalidValue = errors.New("invalid value, should be pointer to struct or slice") // ErrInvalidTransaction invalid transaction when you are trying to `Commit` or `Rollback` ErrInvalidTransaction = errors.New("invalid transaction") )
View Source
var (
ErrInvalidConnForListen = errors.New("conn does not support LISTEN / NOTIFY")
)
View Source
var (
StandardTimeLayout = "2006-01-02 15:04:05"
)
Functions ¶
func MysqlAddress ¶
name will set to be default when empty
Types ¶
type Builder ¶
type Builder interface {
Writer
WriteQuoted(field interface{})
AddVar(vars ...interface{})
}
Builder builder interface
type ConnPool ¶
type ConnPool interface {
PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
}
ConnPool db conns pool interface
type DB ¶
type DB struct {
Statement *Statement
RowsAffected int64
LastInsertId int64
Error error
// contains filtered or unexported fields
}
func (*DB) AddNameMap ¶
func (*DB) QueryReturn ¶
type DataRow ¶
type DataRow struct {
Fields map[string]interface{}
}
func (*DataRow) GetFloat64 ¶
func (*DataRow) GetTimeStr ¶
type Expression ¶
type Expression interface {
Build(builder Builder)
}
Expression expression interface
type Limit ¶
func (Limit) MergeClause ¶
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
func (*Middleware) Close ¶
func (m *Middleware) Close() error
func (*Middleware) Init ¶
func (m *Middleware) Init(opt []mist.Option)
func (*Middleware) Inter ¶
func (m *Middleware) Inter(full bool) mist.Interceptor
type Statement ¶
type Statement struct {
Context context.Context
*DB
Schema *schema.Schema
SQL strings.Builder
Vals []interface{}
Model interface{}
Dest interface{}
ConnPool ConnPool
Clauses map[string]Clause
NameMapper map[string]string
BuildClauses []string
ReflectValue reflect.Value
Table string
}
func (*Statement) WriteQuoted ¶
func (st *Statement) WriteQuoted(value interface{})
type TxBeginner ¶
type TxCommitter ¶
type Where ¶
type Where struct {
Columns []WhereColumn
}
func (*Where) And ¶
func (where *Where) And(field string, quality WhereEquality, value interface{}) WhereColumn
func (Where) MergeClause ¶
func (*Where) Or ¶
func (where *Where) Or(field string, quality WhereEquality, value interface{}) WhereColumn
type WhereColumn ¶
type WhereColumn interface {
C(WhereColumn)
Len() int
IsEmpty() bool
// contains filtered or unexported methods
}
func And ¶
func And(field string, quality, value interface{}) WhereColumn
type WhereEquality ¶
type WhereEquality string
const ( // equal WE_EQ WhereEquality = "=" // not equal WE_NE WhereEquality = "<>" // like WE_LK WhereEquality = "LIKE" // less than WE_LT WhereEquality = "<" // less than or equal to WE_LTE WhereEquality = "<=" // greater than WE_GT WhereEquality = ">" // greater than or equal to WE_GTE WhereEquality = ">=" WE_BETWEEN WhereEquality = "BETWEEN" WE_IN WhereEquality = "IN" )
func ToWhereEquality ¶
func ToWhereEquality(op string) WhereEquality
func (WhereEquality) Equality ¶
func (we WhereEquality) Equality() string
Source Files
¶
Click to show internal directories.
Click to hide internal directories.