Documentation
¶
Index ¶
- func BytesRecords2Models[T Model](brs []BytesRecord, model T) []T
- func DealNotRowsError(err error) error
- func Delete(db Executor, table string, condition condition.Condition) (sql.Result, error)
- func DeleteContext(ctx context.Context, db Executor, table string, condition condition.Condition) (sql.Result, error)
- func DeleteWithRowsAffectedContext(ctx context.Context, db Executor, table string, condition condition.Condition) (rows int64, err error)
- func Exec(db Executor, query string, args ...any) (sql.Result, error)
- func ExecContext(ctx context.Context, db Executor, query string, args ...any) (res sql.Result, err error)
- func ExecWithInsertedIdContext(ctx context.Context, db Executor, query string, args ...any) (insertedId int64, err error)
- func ExecWithRowsAffectedContext(ctx context.Context, db Executor, query string, args ...any) (rows int64, err error)
- func FindAll[T DbModel](db Executor, con condition.Condition, model T, args ...any) ([]T, error)
- func FindAllTimeoutWithPool[T DbModel](timeout time.Duration, pool *Pool, dbType DbType, con condition.Condition, ...) ([]T, error)
- func FindAllWithPoolContext[T DbModel](ctx context.Context, pool *Pool, dbType DbType, con condition.Condition, ...) ([]T, error)
- func FindById[T DbModel](db Executor, id int64, model T, args ...any) (T, error)
- func FindByIdTimeoutWithPool[T DbModel](timeout time.Duration, pool *Pool, dbType DbType, id int64, model T, ...) (T, error)
- func FindByIdWithPoolContext[T DbModel](ctx context.Context, pool *Pool, dbType DbType, id int64, model T, args ...any) (T, error)
- func FindModel[T Model](model T, db Executor, q *helper.Query) (T, error)
- func FindModelByPoolContext[T Model](ctx context.Context, dbType DbType, model T, pool *Pool, q *helper.Query) (m T, err error)
- func FindModelByPoolTimeout[T Model](timeout time.Duration, dbType DbType, model T, pool *Pool, q *helper.Query) (m T, err error)
- func FindModelContext[T Model](ctx context.Context, model T, db Executor, q *helper.Query) (m T, err error)
- func FindModelTimeout[T Model](timeout time.Duration, model T, db Executor, q *helper.Query) (T, error)
- func FindModels[T Model](model T, db Executor, q *helper.Query) ([]T, error)
- func FindModelsByPoolContext[T Model](ctx context.Context, dbType DbType, model T, pool *Pool, q *helper.Query) ([]T, error)
- func FindModelsByPoolTimeout[T Model](timeout time.Duration, dbType DbType, model T, pool *Pool, q *helper.Query) ([]T, error)
- func FindModelsContext[T Model](ctx context.Context, model T, db Executor, q *helper.Query) ([]T, error)
- func FindModelsTimeout[T Model](timeout time.Duration, model T, db Executor, q *helper.Query) ([]T, error)
- func Insert(db Executor, table string, columns helper.Columns, rows ...helper.Row) (sql.Result, error)
- func InsertContext(ctx context.Context, db Executor, table string, columns helper.Columns, ...) (sql.Result, error)
- func InsertWithInsertedIdContext(ctx context.Context, db Executor, table string, columns helper.Columns, ...) (id int64, err error)
- func InsertWithRowsAffectedContext(ctx context.Context, db Executor, table string, columns helper.Columns, ...) (rowsAffected int64, err error)
- func Query(db Executor, query string, args ...any) (*sql.Rows, error)
- func QueryContext(ctx context.Context, db Executor, query string, args ...any) (rows *sql.Rows, err error)
- func QueryRow(db Executor, query string, args ...any) *sql.Row
- func QueryRowContext(ctx context.Context, db Executor, query string, args ...any) (row *sql.Row)
- func ScanModel[T Model](model T, rows *sql.Rows, err error) ([]T, error)
- func Select(db Executor, q *helper.Query) (*sql.Rows, error)
- func SelectContext(ctx context.Context, db Executor, q *helper.Query) (*sql.Rows, error)
- func SetErrorLog(l ErrLog)
- func SetLogger(l LogSql)
- func Update(db Executor, table, setters string, condition condition.Condition, ...) (sql.Result, error)
- func UpdateContext(ctx context.Context, db Executor, table, setters string, ...) (sql.Result, error)
- func UpdateWithRowsAffectedContext(ctx context.Context, db Executor, table, setters string, ...) (rows int64, err error)
- type BytesRecord
- func (br BytesRecord) Bytes(key string) []byte
- func (br BytesRecord) Clone() BytesRecord
- func (br BytesRecord) Exists(key string) bool
- func (br BytesRecord) String(key string) string
- func (br BytesRecord) ToBool(key string) bool
- func (br BytesRecord) ToFloat64(key string) float64
- func (br BytesRecord) ToInt(key string) int
- func (br BytesRecord) ToInt32(key string) int32
- func (br BytesRecord) ToInt64(key string) int64
- func (br BytesRecord) ToInt8(key string) int8
- func (br BytesRecord) ToRecord() Record
- func (br BytesRecord) ToUint32(key string) uint32
- func (br BytesRecord) ToUint64(key string) uint64
- func (br BytesRecord) ToUint8(key string) uint8
- type Db
- func (db *Db) AcquireQuery() *helper.Query
- func (db *Db) Begin() (tx *sql.Tx, err error)
- func (db *Db) BeginTx(ctx context.Context, opts *sql.TxOptions) (tx *sql.Tx, err error)
- func (db *Db) Delete(table string, where condition.Condition) (sql.Result, error)
- func (db *Db) DeleteContext(ctx context.Context, table string, where condition.Condition) (sql.Result, error)
- func (db *Db) DeleteWithRowsAffectedContext(ctx context.Context, table string, where condition.Condition) (rows int64, err error)
- func (db *Db) Executor() Executor
- func (db *Db) Find(q *helper.Query) (records []Record, err error)
- func (db *Db) FindContext(ctx context.Context, q *helper.Query) (records []Record, err error)
- func (db *Db) FindOne(q *helper.Query) (Record, error)
- func (db *Db) FindOneContext(ctx context.Context, q *helper.Query) (Record, error)
- func (db *Db) FindOneTimeout(timeout time.Duration, q *helper.Query) (Record, error)
- func (db *Db) FindTimeout(timeout time.Duration, q *helper.Query) (records []Record, err error)
- func (db *Db) Insert(table string, columns helper.Columns, rows ...helper.Row) (sql.Result, error)
- func (db *Db) InsertContext(ctx context.Context, table string, columns helper.Columns, rows ...helper.Row) (sql.Result, error)
- func (db *Db) InsertWithInsertedIdContext(ctx context.Context, table string, columns helper.Columns, row helper.Row) (id int64, err error)
- func (db *Db) InsertWithInsertedIdTimeout(timeout time.Duration, table string, columns helper.Columns, row helper.Row) (id int64, err error)
- func (db *Db) Options() Options
- func (db *Db) Pool() *sql.DB
- func (db *Db) Update(table string, setter string, where condition.Condition, setterArgs ...any) (sql.Result, error)
- func (db *Db) UpdateContext(ctx context.Context, table string, setter string, where condition.Condition, ...) (sql.Result, error)
- func (db *Db) UpdateWithRowsAffectedContext(ctx context.Context, table string, setter string, where condition.Condition, ...) (rows int64, err error)
- type DbModel
- type DbType
- type ErrLog
- type Executor
- type LogSql
- type Model
- type Options
- type Pool
- func (p *Pool) AcquireQuery() *helper.Query
- func (p *Pool) Begin() (tx *sql.Tx, err error)
- func (p *Pool) BeginTx(ctx context.Context, opts *sql.TxOptions) (tx *sql.Tx, err error)
- func (p *Pool) Close() error
- func (p *Pool) Delete(table string, where condition.Condition) (sql.Result, error)
- func (p *Pool) DeleteContext(ctx context.Context, table string, where condition.Condition) (result sql.Result, err error)
- func (p *Pool) DeleteWithRowsAffectedContext(ctx context.Context, table string, where condition.Condition) (rows int64, err error)
- func (p *Pool) Find(dbType DbType, q *helper.Query) (records []Record, err error)
- func (p *Pool) FindContext(ctx context.Context, dbType DbType, q *helper.Query) (records []Record, err error)
- func (p *Pool) FindOne(dbType DbType, q *helper.Query) (Record, error)
- func (p *Pool) FindOneContext(ctx context.Context, dbType DbType, q *helper.Query) (r Record, err error)
- func (p *Pool) FindOneTimeout(timeout time.Duration, dbType DbType, q *helper.Query) (Record, error)
- func (p *Pool) FindTimeout(timeout time.Duration, dbType DbType, q *helper.Query) (records []Record, err error)
- func (p *Pool) Insert(table string, columns helper.Columns, rows ...helper.Row) (sql.Result, error)
- func (p *Pool) InsertContext(ctx context.Context, table string, columns helper.Columns, rows ...helper.Row) (result sql.Result, err error)
- func (p *Pool) InsertWithInsertedIdContext(ctx context.Context, table string, columns helper.Columns, row helper.Row) (id int64, err error)
- func (p *Pool) Rand(dbType DbType) *Db
- func (p *Pool) RandExecutor(dbType DbType) Executor
- func (p *Pool) Update(table string, setter string, where condition.Condition, setterArgs ...any) (sql.Result, error)
- func (p *Pool) UpdateContext(ctx context.Context, table string, setter string, where condition.Condition, ...) (result sql.Result, err error)
- func (p *Pool) UpdateWithRowsAffectedContext(ctx context.Context, table string, setter string, where condition.Condition, ...) (rows int64, err error)
- type PoolOptions
- type Record
- func Find(db Executor, q *helper.Query) (records []Record, err error)
- func FindContext(ctx context.Context, db Executor, q *helper.Query) (records []Record, err error)
- func FindOne(db Executor, q *helper.Query) (Record, error)
- func FindOneContext(ctx context.Context, db Executor, q *helper.Query) (Record, error)
- func FindOneTimeout(timeout time.Duration, db Executor, q *helper.Query) (Record, error)
- func FindTimeout(timeout time.Duration, db Executor, q *helper.Query) (records []Record, err error)
- func Scan(rows *sql.Rows, err error) ([]Record, error)
- func (r Record) Clone() Record
- func (r Record) Exists(key string) bool
- func (r Record) String(key string) string
- func (r Record) ToBool(key string) bool
- func (r Record) ToBytes(key string) []byte
- func (r Record) ToBytesRecord() BytesRecord
- func (r Record) ToFloat64(key string) float64
- func (r Record) ToInt(key string) int
- func (r Record) ToInt32(key string) int32
- func (r Record) ToInt64(key string) int64
- func (r Record) ToInt8(key string) int8
- func (r Record) ToUint32(key string) uint32
- func (r Record) ToUint64(key string) uint64
- func (r Record) ToUint8(key string) uint8
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesRecords2Models ¶ added in v1.0.3
func BytesRecords2Models[T Model](brs []BytesRecord, model T) []T
func DealNotRowsError ¶ added in v1.1.0
func DeleteContext ¶
func DeleteWithRowsAffectedContext ¶ added in v1.1.0
func ExecContext ¶
func ExecWithInsertedIdContext ¶ added in v1.1.0
func ExecWithRowsAffectedContext ¶ added in v1.1.0
func FindAllTimeoutWithPool ¶ added in v1.0.8
func FindAllWithPoolContext ¶ added in v1.0.8
func FindByIdTimeoutWithPool ¶ added in v1.0.8
func FindByIdWithPoolContext ¶ added in v1.0.8
func FindModelByPoolContext ¶ added in v1.0.8
func FindModelByPoolTimeout ¶ added in v1.0.8
func FindModelContext ¶ added in v1.0.4
func FindModelTimeout ¶ added in v1.0.4
func FindModels ¶ added in v1.0.4
func FindModelsByPoolContext ¶ added in v1.0.8
func FindModelsByPoolTimeout ¶ added in v1.0.8
func FindModelsContext ¶ added in v1.0.4
func FindModelsTimeout ¶ added in v1.0.4
func InsertContext ¶
func InsertWithInsertedIdContext ¶ added in v1.1.0
func InsertWithRowsAffectedContext ¶ added in v1.1.0
func QueryContext ¶
func QueryRowContext ¶ added in v1.0.6
func SelectContext ¶
func SetErrorLog ¶ added in v1.1.0
func SetErrorLog(l ErrLog)
func UpdateContext ¶
Types ¶
type BytesRecord ¶ added in v1.0.3
func ScanBytesRecords ¶ added in v1.0.3
func ScanBytesRecords(rows *sql.Rows, err error) ([]BytesRecord, error)
func (BytesRecord) Bytes ¶ added in v1.0.3
func (br BytesRecord) Bytes(key string) []byte
func (BytesRecord) Clone ¶ added in v1.0.6
func (br BytesRecord) Clone() BytesRecord
func (BytesRecord) Exists ¶ added in v1.0.3
func (br BytesRecord) Exists(key string) bool
func (BytesRecord) String ¶ added in v1.0.3
func (br BytesRecord) String(key string) string
func (BytesRecord) ToBool ¶ added in v1.0.3
func (br BytesRecord) ToBool(key string) bool
func (BytesRecord) ToFloat64 ¶ added in v1.0.3
func (br BytesRecord) ToFloat64(key string) float64
func (BytesRecord) ToInt ¶ added in v1.0.3
func (br BytesRecord) ToInt(key string) int
func (BytesRecord) ToInt32 ¶ added in v1.0.3
func (br BytesRecord) ToInt32(key string) int32
func (BytesRecord) ToInt64 ¶ added in v1.0.3
func (br BytesRecord) ToInt64(key string) int64
func (BytesRecord) ToInt8 ¶ added in v1.0.3
func (br BytesRecord) ToInt8(key string) int8
func (BytesRecord) ToRecord ¶ added in v1.0.5
func (br BytesRecord) ToRecord() Record
func (BytesRecord) ToUint32 ¶ added in v1.0.3
func (br BytesRecord) ToUint32(key string) uint32
func (BytesRecord) ToUint64 ¶ added in v1.0.3
func (br BytesRecord) ToUint64(key string) uint64
func (BytesRecord) ToUint8 ¶ added in v1.0.3
func (br BytesRecord) ToUint8(key string) uint8
type Db ¶
type Db struct {
// contains filtered or unexported fields
}
func (*Db) AcquireQuery ¶
func (*Db) DeleteContext ¶
func (*Db) DeleteWithRowsAffectedContext ¶ added in v1.1.0
func (*Db) FindContext ¶
func (*Db) FindOneContext ¶
func (*Db) FindOneTimeout ¶
func (*Db) FindTimeout ¶
func (*Db) InsertContext ¶
func (*Db) InsertWithInsertedIdContext ¶ added in v1.1.0
func (*Db) InsertWithInsertedIdTimeout ¶ added in v1.1.0
func (*Db) UpdateContext ¶
type Executor ¶
type Executor interface { Query(query string, args ...any) (*sql.Rows, error) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error) QueryRow(query string, args ...any) *sql.Row QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row Exec(query string, args ...any) (sql.Result, error) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) }
type Model ¶ added in v1.0.3
type Model interface { NewModel() Model Assemble(br BytesRecord) }
type Options ¶
type Options struct { DbName string `json:"dbName" yaml:"dbName"` Host string `json:"host" yaml:"host"` Port uint32 `json:"port" yaml:"port"` UserName string `json:"userName" yaml:"userName"` Password string `json:"password" yaml:"password"` CharSet string `json:"charSet" yaml:"charSet"` MaxIdleConns int `json:"maxIdleConns" yaml:"maxIdleConns"` MaxOpenConns int `json:"maxOpenConns" yaml:"maxOpenConns"` ConnMaxIdleTimeSecond int64 `json:"connMaxIdleTimeSecond" yaml:"connMaxIdleTimeSecond"` ConnMaxLifetimeSecond int64 `json:"connMaxLifetimeSecond" yaml:"connMaxLifetimeSecond"` }
func DefaultMysqlOption ¶
func DefaultMysqlOption() Options
func (*Options) ConnMaxIdleTime ¶
func (*Options) ConnMaxLifetime ¶
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
func (*Pool) AcquireQuery ¶ added in v1.0.6
func (*Pool) DeleteContext ¶ added in v1.0.6
func (*Pool) DeleteWithRowsAffectedContext ¶ added in v1.1.0
func (*Pool) FindContext ¶ added in v1.0.6
func (*Pool) FindOneContext ¶ added in v1.0.6
func (*Pool) FindOneTimeout ¶ added in v1.0.6
func (*Pool) FindTimeout ¶ added in v1.0.6
func (*Pool) InsertContext ¶ added in v1.0.6
func (*Pool) InsertWithInsertedIdContext ¶ added in v1.1.0
func (*Pool) RandExecutor ¶ added in v1.1.0
func (*Pool) UpdateContext ¶ added in v1.0.6
type PoolOptions ¶
type Record ¶
func FindContext ¶
func FindOneContext ¶
func FindOneTimeout ¶
func FindTimeout ¶
func (Record) ToBytesRecord ¶ added in v1.0.5
func (r Record) ToBytesRecord() BytesRecord
Source Files
¶
Click to show internal directories.
Click to hide internal directories.