Documentation
¶
Index ¶
- type Chain
- func (c *Chain) BatchValues(values []map[string]interface{}) *Chain
- func (c *Chain) Begin() error
- func (c *Chain) Commit() error
- func (c *Chain) CreateTable(model interface{}) error
- func (c *Chain) Delete() (sql.Result, error)
- func (c *Chain) Fields(fields ...string) *Chain
- func (c *Chain) First() *QueryResult
- func (c *Chain) From(model interface{}) *Chain
- func (c *Chain) Into(dest interface{}) error
- func (c *Chain) IsInTransaction() bool
- func (c *Chain) Last() *QueryResult
- func (c *Chain) Limit(count int) *Chain
- func (c *Chain) List() *QueryResult
- func (c *Chain) Offset(count int) *Chain
- func (c *Chain) One() *QueryResult
- 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) 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 string, value interface{}) *Chain
- 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) 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
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