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, error)
- func (c *Chain) From(model interface{}) *Chain
- func (c *Chain) Into(dest interface{}) error
- func (c *Chain) IsInTransaction() bool
- func (c *Chain) Last() (*QueryResult, error)
- func (c *Chain) Limit(count int) *Chain
- func (c *Chain) List() (*QueryResult, error)
- func (c *Chain) Offset(count int) *Chain
- func (c *Chain) One() (*QueryResult, error)
- func (c *Chain) OrderBy(expr 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, error)
- 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
- 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, error)
List executes a SELECT query and returns all results
func (*Chain) RawExecute ¶
RawExecute executes a raw SQL statement with args
func (*Chain) RawQuery ¶
func (c *Chain) RawQuery(sqlStr string, args ...interface{}) (*QueryResult, error)
RawQuery executes a raw SQL query with args
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
type QueryResult ¶
type QueryResult struct {
Data []map[string]interface{} `json:"data"`
Columns []string `json:"columns"`
}
QueryResult represents a query result
func (*QueryResult) Empty ¶
func (qr *QueryResult) Empty() bool
Empty returns true if the result is empty
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