Documentation ¶
Index ¶
- func DeleteSQL(opts ...Option) (string, []interface{})
- func InsertSQL(opts ...Option) (string, []interface{})
- func ReplaceSQL(opts ...Option) (string, []interface{})
- func Select(opts ...Option) (string, []interface{})
- func UpdateSQL(opts ...Option) (string, []interface{})
- type Add
- type Clause
- type Cluster
- type DB
- type Error
- type Executor
- type Option
- func Columns(fields ...string) Option
- func CorssJoin(table string, conditionA, logic, conditionB string) Option
- func Flag(flags ...string) Option
- func ForUpdate(n int) Option
- func GroupBy(fields ...string) Option
- func InnerJoin(table string, conditionA, logic, conditionB string) Option
- func Join(table string, conditionA, logic, conditionB string) Option
- func LeftJoin(table string, conditionA, logic, conditionB string) Option
- func Limit(n int) Option
- func Offset(n int) Option
- func OrWhere(key interface{}, vals ...interface{}) Option
- func OrderBy(fields ...string) Option
- func RightJoin(table string, conditionA, logic, conditionB string) Option
- func Set(key string, val interface{}) Option
- func Table(name interface{}) Option
- func Where(key interface{}, vals ...interface{}) Option
- type PoolCluster
- func (c *PoolCluster) Begin() (*Session, error)
- func (c *PoolCluster) Delete(dst interface{}, opts ...Option) (Result, error)
- func (c *PoolCluster) Fetch(dst interface{}, opts ...Option) error
- func (c *PoolCluster) FetchAll(dst interface{}, opts ...Option) error
- func (c *PoolCluster) Insert(dst interface{}, opts ...Option) (Result, error)
- func (c *PoolCluster) Master() (Executor, error)
- func (c *PoolCluster) Replace(dst interface{}, opts ...Option) (Result, error)
- func (c *PoolCluster) Session() (*Session, error)
- func (c *PoolCluster) SessionContext(ctx context.Context) (*Session, error)
- func (c *PoolCluster) Slave(v uint64) (Executor, error)
- func (c *PoolCluster) Update(dst interface{}, opts ...Option) (Result, error)
- type PoolClusterOpts
- type Result
- type SQLSegments
- func (s *SQLSegments) Args() []interface{}
- func (s *SQLSegments) Build() (string, []interface{})
- func (s *SQLSegments) BuildDelete() string
- func (s *SQLSegments) BuildInsert() string
- func (s *SQLSegments) BuildReplace() string
- func (s *SQLSegments) BuildSelect() string
- func (s *SQLSegments) BuildUpdate() string
- func (s *SQLSegments) CorssJoin(table string, conditionA, logic, conditionB string) *SQLSegments
- func (s *SQLSegments) Delete() *SQLSegments
- func (s *SQLSegments) Field(fields ...string) *SQLSegments
- func (s *SQLSegments) Flag(flags ...string) *SQLSegments
- func (s *SQLSegments) ForUpdate() *SQLSegments
- func (s *SQLSegments) GroupBy(fields ...string) *SQLSegments
- func (s *SQLSegments) Having(key interface{}, vals ...interface{}) *SQLSegments
- func (s *SQLSegments) InnerJoin(table string, conditionA, logic, conditionB string) *SQLSegments
- func (s *SQLSegments) Insert(vals ...map[string]interface{}) *SQLSegments
- func (s *SQLSegments) IsEmptyWhereClause() bool
- func (s *SQLSegments) Join(table string, conditionA, logic, conditionB string) *SQLSegments
- func (s *SQLSegments) LeftJoin(table string, conditionA, logic, conditionB string) *SQLSegments
- func (s *SQLSegments) Limit(n int) *SQLSegments
- func (s *SQLSegments) Offset(n int) *SQLSegments
- func (s *SQLSegments) OrWhere(key interface{}, vals ...interface{}) *SQLSegments
- func (s *SQLSegments) OrderBy(fields ...string) *SQLSegments
- func (s *SQLSegments) RightJoin(table string, conditionA, logic, conditionB string) *SQLSegments
- func (s *SQLSegments) Table(name interface{}) *SQLSegments
- func (s *SQLSegments) Union(f func(*SQLSegments)) *SQLSegments
- func (s *SQLSegments) UnsafeUpdate(vals map[string]interface{}) *SQLSegments
- func (s *SQLSegments) Update(vals map[string]interface{}) *SQLSegments
- func (s *SQLSegments) UpdateField(key string, val interface{}) *SQLSegments
- func (s *SQLSegments) Where(key interface{}, vals ...interface{}) *SQLSegments
- type Session
- func (s *Session) Commit() error
- func (s *Session) Delete(dst interface{}, opts ...Option) (Result, error)
- func (s *Session) Exec(query string, args ...interface{}) (sql.Result, error)
- func (s *Session) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (s *Session) Executor(master bool) (Executor, error)
- func (s *Session) Fetch(dst interface{}, opts ...Option) error
- func (s *Session) FetchAll(dst interface{}, opts ...Option) error
- func (s *Session) Insert(dst interface{}, opts ...Option) (Result, error)
- func (s *Session) Master() *Session
- func (s *Session) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (s *Session) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (s *Session) QueryRow(query string, args ...interface{}) *sql.Row
- func (s *Session) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
- func (s *Session) Replace(dst interface{}, opts ...Option) (Result, error)
- func (s *Session) Rollback() error
- func (s *Session) Update(dst interface{}, opts ...Option) (Result, error)
- type SessionOpts
- type Sub
- type TbName
- type Tx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Clause ¶
type Clause struct {
// contains filtered or unexported fields
}
Clause ...
type Cluster ¶
type Cluster interface { Master() (Executor, error) Slave(v uint64) (Executor, error) Session() (*Session, error) SessionContext(ctx context.Context) (*Session, error) Begin() (*Session, error) Fetch(dst interface{}, opts ...Option) error FetchAll(dst interface{}, opts ...Option) error Update(dst interface{}, opts ...Option) (Result, error) Insert(dst interface{}, opts ...Option) (Result, error) Replace(dst interface{}, opts ...Option) (Result, error) Delete(dst interface{}, opts ...Option) (Result, error) }
Cluster ..
type DB ¶
type DB interface { SetMaxIdleConns(n int) SetMaxOpenConns(n int) SetConnMaxLifetime(d time.Duration) Stats() sql.DBStats PingContext(ctx context.Context) error Ping() error Close() error BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error) Begin() (*sql.Tx, error) Driver() driver.Driver Conn(ctx context.Context) (*sql.Conn, error) }
DB ..
type Executor ¶
type Executor interface { PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) Prepare(query string) (*sql.Stmt, error) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) Exec(query string, args ...interface{}) (sql.Result, error) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) Query(query string, args ...interface{}) (*sql.Rows, error) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row QueryRow(query string, args ...interface{}) *sql.Row }
Executor is a Executor
type Option ¶
type Option func(q SQLSegments) SQLSegments
Option ..
type PoolCluster ¶
type PoolCluster struct {
// contains filtered or unexported fields
}
PoolCluster ..
func (*PoolCluster) Delete ¶
func (c *PoolCluster) Delete(dst interface{}, opts ...Option) (Result, error)
Delete delete record
func (*PoolCluster) Fetch ¶
func (c *PoolCluster) Fetch(dst interface{}, opts ...Option) error
Fetch fetch record to model
func (*PoolCluster) FetchAll ¶
func (c *PoolCluster) FetchAll(dst interface{}, opts ...Option) error
FetchAll fetch records to models
func (*PoolCluster) Insert ¶
func (c *PoolCluster) Insert(dst interface{}, opts ...Option) (Result, error)
Insert insert from model
func (*PoolCluster) Master ¶
func (c *PoolCluster) Master() (Executor, error)
Master select db to master
func (*PoolCluster) Replace ¶
func (c *PoolCluster) Replace(dst interface{}, opts ...Option) (Result, error)
Replace replace from model
func (*PoolCluster) SessionContext ¶
func (c *PoolCluster) SessionContext(ctx context.Context) (*Session, error)
SessionContext ..
type SQLSegments ¶
type SQLSegments struct {
// contains filtered or unexported fields
}
SQLSegments ...
func (*SQLSegments) CorssJoin ¶
func (s *SQLSegments) CorssJoin(table string, conditionA, logic, conditionB string) *SQLSegments
CorssJoin SQLSegments
func (*SQLSegments) Field ¶
func (s *SQLSegments) Field(fields ...string) *SQLSegments
Field SQLSegments
func (*SQLSegments) Flag ¶
func (s *SQLSegments) Flag(flags ...string) *SQLSegments
Flag SQLSegments
func (*SQLSegments) ForUpdate ¶
func (s *SQLSegments) ForUpdate() *SQLSegments
ForUpdate SQLSegments
func (*SQLSegments) GroupBy ¶
func (s *SQLSegments) GroupBy(fields ...string) *SQLSegments
GroupBy SQLSegments
func (*SQLSegments) Having ¶
func (s *SQLSegments) Having(key interface{}, vals ...interface{}) *SQLSegments
Having ...
func (*SQLSegments) InnerJoin ¶
func (s *SQLSegments) InnerJoin(table string, conditionA, logic, conditionB string) *SQLSegments
InnerJoin SQLSegments
func (*SQLSegments) Insert ¶
func (s *SQLSegments) Insert(vals ...map[string]interface{}) *SQLSegments
Insert ...
func (*SQLSegments) IsEmptyWhereClause ¶
func (s *SQLSegments) IsEmptyWhereClause() bool
IsEmptyWhereClause ...
func (*SQLSegments) Join ¶
func (s *SQLSegments) Join(table string, conditionA, logic, conditionB string) *SQLSegments
Join SQLSegments
func (*SQLSegments) LeftJoin ¶
func (s *SQLSegments) LeftJoin(table string, conditionA, logic, conditionB string) *SQLSegments
LeftJoin SQLSegments
func (*SQLSegments) OrWhere ¶
func (s *SQLSegments) OrWhere(key interface{}, vals ...interface{}) *SQLSegments
OrWhere ..
func (*SQLSegments) OrderBy ¶
func (s *SQLSegments) OrderBy(fields ...string) *SQLSegments
OrderBy SQLSegments
func (*SQLSegments) RightJoin ¶
func (s *SQLSegments) RightJoin(table string, conditionA, logic, conditionB string) *SQLSegments
RightJoin SQLSegments
func (*SQLSegments) Table ¶
func (s *SQLSegments) Table(name interface{}) *SQLSegments
Table SQLSegments
func (*SQLSegments) Union ¶
func (s *SQLSegments) Union(f func(*SQLSegments)) *SQLSegments
Union ...
func (*SQLSegments) UnsafeUpdate ¶
func (s *SQLSegments) UnsafeUpdate(vals map[string]interface{}) *SQLSegments
UnsafeUpdate 可以没有where条件更新 ,Update 更新必须指定where条件才能更新否则panic
func (*SQLSegments) Update ¶
func (s *SQLSegments) Update(vals map[string]interface{}) *SQLSegments
Update ..
func (*SQLSegments) UpdateField ¶
func (s *SQLSegments) UpdateField(key string, val interface{}) *SQLSegments
UpdateField 更新字段
func (*SQLSegments) Where ¶
func (s *SQLSegments) Where(key interface{}, vals ...interface{}) *SQLSegments
Where ..
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session ..
func (*Session) ExecContext ¶
func (s *Session) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
ExecContext ..
func (*Session) QueryContext ¶
func (s *Session) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
QueryContext ..
func (*Session) QueryRowContext ¶
QueryRowContext ..