Documentation ¶
Index ¶
- Constants
- type JoinType
- type Session
- func (s *Session) Begin() (err error)
- func (s *Session) CallMethod(method string, value interface{})
- func (s *Session) Clear()
- func (s *Session) Commit() (err error)
- func (s *Session) Count() (int64, error)
- func (s *Session) Create(values interface{}) (int64, error)
- func (s *Session) Delete() (int64, error)
- func (s *Session) DropTable() error
- func (s *Session) Find(values interface{}) error
- func (s *Session) First(value interface{}) error
- func (s *Session) GetIntFromInterface(val interface{}) (int, error)
- func (s *Session) GetTableFromNone(tableName string) ([]string, error)
- func (s *Session) GetTableFromTableAndSplitFiled(tableName string, splitFiledVal interface{}) (string, error)
- func (s *Session) GetTimeFromInterface(val interface{}) (time.Time, error)
- func (s *Session) GroupBy(desc string) *Session
- func (s *Session) Having(desc string, args ...interface{}) *Session
- func (s *Session) Join(joinType JoinType, desc string, args ...interface{}) *Session
- func (s *Session) Limit(num int) *Session
- func (s *Session) Model(value interface{}) *Session
- func (s *Session) Offset(num int) *Session
- func (s *Session) Omit(field ...string) *Session
- func (s *Session) Or(desc string, args ...interface{}) *Session
- func (s *Session) OrderBy(desc string) *Session
- func (s *Session) Query(ctx context.Context, db *sql.DB, dia dialect.Dialect, sqlInfo string, ...) error
- func (s *Session) QueryPagination(ctx context.Context, db *sql.DB, dia dialect.Dialect, sqlInfo string, ...) (err error)
- func (s *Session) QueryRowContext(ctx context.Context, db *sql.DB, dia dialect.Dialect, sqlInfo string, ...) *sql.Row
- func (s *Session) Raw(sql string, values ...interface{}) *Session
- func (s *Session) RefTable() *schema.Schema
- func (s *Session) Rollback() (err error)
- func (s *Session) Select(field ...string) *Session
- func (s *Session) Table(table string) *Session
- func (s *Session) Update(desc string, args ...interface{}) (int64, error)
- func (s *Session) Where(desc string, args ...interface{}) *Session
- func (s *Session) WithContext(ctx context.Context) *Session
Constants ¶
View Source
const ( BeforeQuery = "BeforeQuery" AfterQuery = "AfterQuery" BeforeUpdate = "BeforeUpdate" AfterUpdate = "AfterUpdate" BeforeDelete = "BeforeDelete" AfterDelete = "AfterDelete" BeforeInsert = "BeforeInsert" AfterInsert = "AfterInsert" )
Hooks constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session keep a pointer to sql.DB and provides all execution of all kind of database operations.
func New ¶
func New(db *server.DB, split *map[string]spliter.Split, dbs map[string]*server.DB, opt operator.Operator, config *server.Config) *Session
New creates instance of Session
func (*Session) CallMethod ¶
s.CallMethod(BeforeUpdate, nil) CallMethod calls the registered hooks
func (*Session) GetIntFromInterface ¶
输入一个interface{}类型的值,返回一个int 类型的值
func (*Session) GetTableFromNone ¶
仅支持获取以数字 分表的选手
func (*Session) GetTableFromTableAndSplitFiled ¶
func (s *Session) GetTableFromTableAndSplitFiled(tableName string, splitFiledVal interface{}) (string, error)
GetTableFromTableAndSplitFiled 根据表名和分表字段获取表名 如果分表字段为空,就返回原来的表名 tableName 表名 splitFiledVal 分表字段的值 一般只有两种类型 一个是int 一个是time.Time
func (*Session) GetTimeFromInterface ¶
输入一个interface{}类型的值,返回一个time.Time 类型的值
func (*Session) Query ¶
func (s *Session) Query(ctx context.Context, db *sql.DB, dia dialect.Dialect, sqlInfo string, args []interface{}, list interface{}) error
Query QueryRow gets a record from db
func (*Session) QueryPagination ¶
func (s *Session) QueryPagination(ctx context.Context, db *sql.DB, dia dialect.Dialect, sqlInfo string, args []interface{}, limit, offset int, list interface{}) (err error)
QueryPagination QueryRow gets a record from db
func (*Session) QueryRowContext ¶
Click to show internal directories.
Click to hide internal directories.