Documentation ¶
Index ¶
- Variables
- func AsAssignments(db DBExecutor, model builder.Model, zeroFields ...string) builder.Assignments
- func DBErr(err error) *dbErr
- func FieldValuesFromModel(table *builder.Table, model builder.Model, zeroFields ...string) builder.FieldValues
- func InsertToDB(db DBExecutor, model builder.Model, zeroFields []string, ...) builder.SqlExpr
- func Scan(rows *sql.Rows, v interface{}) error
- type DB
- func (d *DB) Begin() (DBExecutor, error)
- func (d *DB) BeginTx(opt *sql.TxOptions) (DBExecutor, error)
- func (d *DB) Commit() error
- func (d *DB) Context() context.Context
- func (d *DB) D() *Database
- func (d *DB) Dialect() builder.Dialect
- func (d *DB) ExecExpr(expr builder.SqlExpr) (sql.Result, error)
- func (d *DB) IsTx() bool
- func (d *DB) Migrate(ctx context.Context, db DBExecutor) error
- func (d *DB) QueryExpr(expr builder.SqlExpr) (*sql.Rows, error)
- func (d *DB) QueryExprAndScan(expr builder.SqlExpr, v interface{}) error
- func (d *DB) Rollback() error
- func (d *DB) SetConnMaxLifetime(t time.Duration)
- func (d *DB) SetMaxIdleConns(n int)
- func (d *DB) SetMaxOpenConns(n int)
- func (d *DB) WithContext(ctx context.Context) DBExecutor
- func (d DB) WithSchema(schema string) DBExecutor
- type DBExecutor
- type DBNameBinder
- type Database
- func (database *Database) AddTable(table *builder.Table)
- func (database *Database) OpenDB(connector driver.Connector) *DB
- func (database *Database) Register(model builder.Model) *builder.Table
- func (database *Database) T(model builder.Model) *builder.Table
- func (database *Database) Table(tableName string) *builder.Table
- func (database Database) WithSchema(schema string) *Database
- type MaybeTxExecutor
- type Migrator
- type ScanIterator
- type SqlError
- type SqlExecutor
- type SqlxExecutor
- type Task
- type Tasks
Constants ¶
This section is empty.
Variables ¶
View Source
var DuplicateEntryErrNumber uint16 = 1062
View Source
var ErrNotDB = errors.New("db is not *sql.DB")
View Source
var ErrNotTx = errors.New("db is not *sql.Tx")
Functions ¶
func AsAssignments ¶ added in v2.6.0
func AsAssignments(db DBExecutor, model builder.Model, zeroFields ...string) builder.Assignments
func FieldValuesFromModel ¶ added in v2.6.0
func InsertToDB ¶ added in v2.6.0
Types ¶
type DB ¶
type DB struct { *Database SqlExecutor // contains filtered or unexported fields }
func (*DB) Begin ¶
func (d *DB) Begin() (DBExecutor, error)
func (*DB) QueryExprAndScan ¶
func (*DB) SetConnMaxLifetime ¶
func (*DB) SetMaxIdleConns ¶
func (*DB) SetMaxOpenConns ¶
func (*DB) WithContext ¶ added in v2.7.0
func (d *DB) WithContext(ctx context.Context) DBExecutor
func (DB) WithSchema ¶ added in v2.2.2
func (d DB) WithSchema(schema string) DBExecutor
type DBExecutor ¶ added in v2.6.0
type DBExecutor interface { SqlxExecutor // dialect of databases Dialect() builder.Dialect // return database which is connecting D() *Database // switch database schema WithSchema(schema string) DBExecutor // return table of the connecting database T(model builder.Model) *builder.Table Context() context.Context WithContext(ctx context.Context) DBExecutor }
type DBNameBinder ¶
type Database ¶
func NewDatabase ¶
func NewFeatureDatabase ¶
func (Database) WithSchema ¶ added in v2.2.2
type MaybeTxExecutor ¶ added in v2.6.0
type MaybeTxExecutor interface { IsTx() bool BeginTx(*sql.TxOptions) (DBExecutor, error) Begin() (DBExecutor, error) Commit() error Rollback() error }
type Migrator ¶ added in v2.6.0
type Migrator interface {
Migrate(ctx context.Context, db DBExecutor) error
}
type ScanIterator ¶ added in v2.9.0
type ScanIterator interface { // new a ptr value for scan New() interface{} // for receive scanned value Next(v interface{}) error }
type SqlExecutor ¶
type SqlxExecutor ¶ added in v2.6.0
type Task ¶
type Task func(db DBExecutor) error
func (Task) Run ¶
func (task Task) Run(db DBExecutor) (err error)
Click to show internal directories.
Click to hide internal directories.