Documentation
¶
Index ¶
- Variables
- func DeleteSQL(opts ...Option) (string, []interface{})
- func InsertSQL(opts ...Option) (string, []interface{})
- func NewCollect(clst Cluster, name ...string)
- func ReplaceSQL(opts ...Option) (string, []interface{})
- func SelectSQL(opts ...Option) (string, []interface{})
- func UpdateSQL(opts ...Option) (string, []interface{})
- type Add
- type Clause
- type Cluster
- type DB
- type DbOption
- 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() 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 Params(vals ...map[string]interface{}) Option
- func Returning() Option
- func RightJoin(table string, conditionA, logic, conditionB string) Option
- func Set(key string, val interface{}) Option
- func Table(name interface{}) Option
- func Union(f func(*SQLSegments)) 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) Exec(query string, args ...interface{}) (sql.Result, error)
- func (c *PoolCluster) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.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) Primary() (*Session, error)
- func (c *PoolCluster) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (c *PoolCluster) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (c *PoolCluster) QueryRow(query string, args ...interface{}) *sql.Row
- func (c *PoolCluster) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
- func (c *PoolCluster) Replace(dst interface{}, opts ...Option) (Result, error)
- func (c *PoolCluster) Replica() (*Session, 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) Params(vals ...map[string]interface{}) *SQLSegments
- func (s *SQLSegments) Returning() *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() (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) 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 Sub
- type TbName
- type Tx
Constants ¶
This section is empty.
Variables ¶
var Debug = false
Debug env
var ErrNoRows = sql.ErrNoRows
ErrNoRows sql ErrNoRows
Functions ¶
Types ¶
type Clause ¶
type Clause struct {
// contains filtered or unexported fields
}
Clause ...
type Cluster ¶
type Cluster interface { // Executor(*Session, bool) (*Session, error) Begin() (*Session, error) Fetch(interface{}, ...Option) error FetchAll(interface{}, ...Option) error Update(interface{}, ...Option) (Result, error) Insert(interface{}, ...Option) (Result, error) Replace(interface{}, ...Option) (Result, error) Delete(interface{}, ...Option) (Result, error) }
Cluster ..
type DB ¶
type DB interface { SetMaxIdleConns(int) SetMaxOpenConns(int) SetConnMaxLifetime(time.Duration) Stats() sql.DBStats PingContext(context.Context) error Ping() error Close() error BeginTx(context.Context, *sql.TxOptions) (*sql.Tx, error) Begin() (*sql.Tx, error) Driver() driver.Driver Conn(context.Context) (*sql.Conn, error) }
DB ..
type Executor ¶
type Executor interface { PrepareContext(context.Context, string) (*sql.Stmt, error) Prepare(string) (*sql.Stmt, error) ExecContext(context.Context, string, ...interface{}) (sql.Result, error) Exec(string, ...interface{}) (sql.Result, error) QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error) Query(string, ...interface{}) (*sql.Rows, error) QueryRowContext(context.Context, string, ...interface{}) *sql.Row QueryRow(string, ...interface{}) *sql.Row }
Executor is a Executor
type Option ¶
type Option func(q SQLSegments) SQLSegments
Option is SQL segment part
type PoolCluster ¶
type PoolCluster struct {
// contains filtered or unexported fields
}
PoolCluster impl Cluster
func (*PoolCluster) Delete ¶
func (c *PoolCluster) Delete(dst interface{}, opts ...Option) (Result, error)
Delete delete record
func (*PoolCluster) Exec ¶
func (c *PoolCluster) Exec(query string, args ...interface{}) (sql.Result, error)
Exec ..
func (*PoolCluster) ExecContext ¶
func (c *PoolCluster) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
ExecContext ..
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) Primary ¶
func (c *PoolCluster) Primary() (*Session, error)
Primary select primary db
func (*PoolCluster) Query ¶
func (c *PoolCluster) Query(query string, args ...interface{}) (*sql.Rows, error)
Query ..
func (*PoolCluster) QueryContext ¶
func (c *PoolCluster) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
QueryContext ..
func (*PoolCluster) QueryRow ¶
func (c *PoolCluster) QueryRow(query string, args ...interface{}) *sql.Row
QueryRow ..
func (*PoolCluster) QueryRowContext ¶
func (c *PoolCluster) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
QueryRowContext ..
func (*PoolCluster) Replace ¶
func (c *PoolCluster) Replace(dst interface{}, opts ...Option) (Result, error)
Replace replace from model
func (*PoolCluster) Replica ¶
func (c *PoolCluster) Replica() (*Session, error)
Replica select replica db
type SQLSegments ¶
type SQLSegments struct {
// contains filtered or unexported fields
}
SQLSegments ...
func (*SQLSegments) Build ¶
func (s *SQLSegments) Build() (string, []interface{})
Build for build a sql with SQLSegments
func (*SQLSegments) BuildDelete ¶
func (s *SQLSegments) BuildDelete() string
BuildDelete build a delete sql
func (*SQLSegments) BuildReplace ¶
func (s *SQLSegments) BuildReplace() string
BuildReplace build a replace sql
func (*SQLSegments) BuildUpdate ¶
func (s *SQLSegments) BuildUpdate() string
BuildUpdate build a update sql
func (*SQLSegments) CorssJoin ¶
func (s *SQLSegments) CorssJoin(table string, conditionA, logic, conditionB string) *SQLSegments
CorssJoin SQLSegments
func (*SQLSegments) Delete ¶
func (s *SQLSegments) Delete() *SQLSegments
Delete for a part of delete sql
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) Params ¶
func (s *SQLSegments) Params(vals ...map[string]interface{}) *SQLSegments
Params ...
func (*SQLSegments) Returning ¶
func (s *SQLSegments) Returning() *SQLSegments
Returning 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 for set a field when update sql
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 ..