Documentation
¶
Index ¶
- type Chain
- func (c *Chain) Avg(field string) (float64, error)
- func (c *Chain) BatchValues(values []map[string]interface{}) *Chain
- func (c *Chain) Begin() error
- func (c *Chain) Between(field string, start, end interface{}) *Chain
- func (c *Chain) Commit() error
- func (c *Chain) Count() (int64, error)
- func (c *Chain) CreateTable(model interface{}) error
- func (c *Chain) Delete() (sql.Result, error)
- func (c *Chain) Eq(field string, value interface{}) *Chain
- func (c *Chain) Fields(fields ...string) *Chain
- func (c *Chain) First() *QueryResult
- func (c *Chain) From(model interface{}) *Chain
- func (c *Chain) Ge(field string, value interface{}) *Chain
- func (c *Chain) Gt(field string, value interface{}) *Chain
- func (c *Chain) In(field string, value interface{}) *Chain
- func (c *Chain) Into(dest interface{}) error
- func (c *Chain) IsInTransaction() bool
- func (c *Chain) IsNotNull(field string) *Chain
- func (c *Chain) IsNull(field string) *Chain
- func (c *Chain) Last() *QueryResult
- func (c *Chain) Le(field string, value interface{}) *Chain
- func (c *Chain) Like(field string, value interface{}) *Chain
- func (c *Chain) Limit(count int) *Chain
- func (c *Chain) List() *QueryResult
- func (c *Chain) Lt(field string, value interface{}) *Chain
- func (c *Chain) Ne(field string, value interface{}) *Chain
- func (c *Chain) NewCondition() *define.Condition
- func (c *Chain) NotBetween(field string, start, end interface{}) *Chain
- func (c *Chain) NotIn(field string, value interface{}) *Chain
- func (c *Chain) NotLike(field string, value interface{}) *Chain
- func (c *Chain) Offset(count int) *Chain
- func (c *Chain) One() *QueryResult
- func (c *Chain) OrBetween(field string, start, end interface{}) *Chain
- func (c *Chain) OrEq(field string, value interface{}) *Chain
- func (c *Chain) OrGe(field string, value interface{}) *Chain
- func (c *Chain) OrGt(field string, value interface{}) *Chain
- func (c *Chain) OrIn(field string, value interface{}) *Chain
- func (c *Chain) OrIsNotNull(field string) *Chain
- func (c *Chain) OrIsNull(field string) *Chain
- func (c *Chain) OrLe(field string, value interface{}) *Chain
- func (c *Chain) OrLike(field string, value interface{}) *Chain
- func (c *Chain) OrLt(field string, value interface{}) *Chain
- func (c *Chain) OrNe(field string, value interface{}) *Chain
- func (c *Chain) OrNotBetween(field string, start, end interface{}) *Chain
- func (c *Chain) OrNotIn(field string, value interface{}) *Chain
- func (c *Chain) OrNotLike(field string, value interface{}) *Chain
- func (c *Chain) OrWhereGroup() *define.Condition
- func (c *Chain) OrderBy(field string) *Chain
- func (c *Chain) OrderByDesc(field string) *Chain
- func (c *Chain) Page(pageNum, pageSize int) *Chain
- func (c *Chain) RawExecute(sql string, args ...interface{}) (sql.Result, error)
- func (c *Chain) RawQuery(sqlStr string, args ...interface{}) *QueryResult
- func (c *Chain) ReleaseSavepoint(name string) error
- func (c *Chain) Rollback() error
- func (c *Chain) RollbackTo(name string) error
- func (c *Chain) Save() (define.Result, error)
- func (c *Chain) Savepoint(name string) error
- func (c *Chain) Set(field string, value interface{}) *Chain
- func (c *Chain) SetIsolationLevel(level sql.IsolationLevel) *Chain
- func (c *Chain) Sum(field string) (float64, error)
- func (c *Chain) Table(table string) *Chain
- func (c *Chain) Transaction(fn func(*Chain) error) error
- func (c *Chain) Update() (sql.Result, error)
- func (c *Chain) Values(fields map[string]interface{}) *Chain
- func (c *Chain) Where(field string, op define.OpType, value interface{}) *Chain
- func (c *Chain) Where2(cond *define.Condition) *Chain
- func (c *Chain) WhereGroup() *define.Condition
- type DB
- func (db *DB) Chain() *Chain
- func (db *DB) Close() error
- func (db *DB) GenerateStruct(tableName, outputDir, packageName string) error
- func (db *DB) GenerateStructs(opts GenerateOptions) error
- func (db *DB) GetTableInfo(tableName string) (*define.TableInfo, error)
- func (db *DB) GetTables(pattern string) ([]string, error)
- type GenerateOptions
- type OrderBy
- type OrderType
- type QueryResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain represents the base chain structure
func (*Chain) BatchValues ¶
BatchValues sets batch insert values
func (*Chain) CreateTable ¶
CreateTable creates a table based on the model struct
func (*Chain) IsInTransaction ¶
IsInTransaction returns whether the chain is currently in a transaction
func (*Chain) List ¶
func (c *Chain) List() *QueryResult
List executes a SELECT query and returns all results
func (*Chain) NewCondition ¶ added in v4.1.3
NewCondition creates a new condition with AND join type
func (*Chain) NotBetween ¶ added in v4.1.3
NotBetween adds a NOT BETWEEN condition
func (*Chain) OrIsNotNull ¶ added in v4.1.3
OrIsNotNull adds an OR IS NOT NULL condition
func (*Chain) OrNotBetween ¶ added in v4.1.3
OrNotBetween adds an OR NOT BETWEEN condition
func (*Chain) OrWhereGroup ¶ added in v4.1.3
OrWhereGroup starts a new condition group with OR join type
func (*Chain) OrderByDesc ¶
OrderByDesc adds a descending order by clause
func (*Chain) RawExecute ¶
RawExecute executes a raw SQL statement with args
func (*Chain) RawQuery ¶
func (c *Chain) RawQuery(sqlStr string, args ...interface{}) *QueryResult
RawQuery executes a raw SQL query
func (*Chain) ReleaseSavepoint ¶
ReleaseSavepoint releases the specified savepoint
func (*Chain) RollbackTo ¶
RollbackTo rolls back to the specified savepoint
func (*Chain) SetIsolationLevel ¶
func (c *Chain) SetIsolationLevel(level sql.IsolationLevel) *Chain
SetIsolationLevel sets the isolation level for the next transaction
func (*Chain) Transaction ¶
Transaction executes a function within a transaction
func (*Chain) WhereGroup ¶ added in v4.1.3
WhereGroup starts a new condition group with AND join type
type DB ¶
type DB struct { DB *sql.DB Factory define.SQLFactory RoutineID int64 }
DB represents the database connection
func (*DB) GenerateStruct ¶
GenerateStruct 生成单个表的结构体代码
func (*DB) GenerateStructs ¶
func (db *DB) GenerateStructs(opts GenerateOptions) error
GenerateStructs 批量生成表的结构体代码
func (*DB) GetTableInfo ¶
GetTableInfo 获取表信息
type GenerateOptions ¶
type GenerateOptions struct { OutputDir string // 输出目录 PackageName string // 包名 Pattern string // 表名匹配模式 }
GenerateOptions 代码生成选项
type QueryResult ¶
type QueryResult struct { Data []map[string]interface{} `json:"data"` Columns []string `json:"columns"` // contains filtered or unexported fields }
QueryResult represents a query result
func (*QueryResult) Empty ¶
func (qr *QueryResult) Empty() bool
Empty returns true if the result is empty
func (*QueryResult) First ¶
func (qr *QueryResult) First() *QueryResult
First returns the first result or error if no results
func (*QueryResult) Into ¶
func (qr *QueryResult) Into(dest interface{}) error
Into scans the result into a slice of structs
func (*QueryResult) Size ¶
func (qr *QueryResult) Size() int
Size returns the number of rows in the result