zdb

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

*

  • @Author : nopsky
  • @Email : cnnopsky@gmail.com
  • @Date : 2021/4/2 13:47

*

  • @Author : nopsky
  • @Email : cnnopsky@gmail.com
  • @Date : 2021/3/11 15:25

*

  • @Author : nopsky
  • @Email : cnnopsky@gmail.com
  • @Date : 2021/3/11 15:26

*

  • @Author : nopsky
  • @Email : cnnopsky@gmail.com
  • @Date : 2021/6/26 16:56

*

  • @Author : nopsky
  • @Email : cnnopsky@gmail.com
  • @Date : 2021/3/18 14:03

*

  • @Author : nopsky
  • @Email : cnnopsky@gmail.com
  • @Date : 2021/3/11 15:26

*

  • @Author : nopsky
  • @Email : cnnopsky@gmail.com
  • @Date : 2021/3/11 15:26

*

  • @Author : nopsky
  • @Email : cnnopsky@gmail.com
  • @Date : 2021/3/11 17:14

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRecordNotFound record not found error
	ErrRecordNotFound = errors.New("not found")
	// ErrInvalidTransaction invalid transaction when you are trying to `Commit` or `Rollback`
	ErrInvalidTransaction = errors.New("invalid transaction")
	// ErrNotImplemented not implemented
	ErrNotImplemented = errors.New("not implemented")
	// ErrMissingWhereClause missing where clause
	ErrMissingWhereClause = errors.New("WHERE conditions required")
	// ErrUnsupportedRelation unsupported relations
	ErrUnsupportedRelation = errors.New("unsupported relations")
	// ErrPrimaryKeyRequired primary keys required
	ErrPrimaryKeyRequired = errors.New("primary key required")
	// ErrModelValueRequired model value required
	ErrModelValueRequired = errors.New("model value required")
	// ErrInvalidData unsupported data
	ErrInvalidData = errors.New("unsupported data")
	// ErrUnsupportedDriver unsupported driver
	ErrUnsupportedDriver = errors.New("unsupported driver")
	// ErrRegistered registered
	ErrRegistered = errors.New("registered")
	// ErrInvalidField invalid field
	ErrInvalidField = errors.New("invalid field")
	// ErrEmptySlice empty slice found
	ErrEmptySlice = errors.New("empty slice found")
	// ErrDryRunModeUnsupported dry run mode unsupported
	ErrDryRunModeUnsupported = errors.New("dry run mode unsupported")
	// ErrInvalidDB invalid db
	ErrInvalidDB = errors.New("invalid db")
	// ErrInvalidValue invalid value
	ErrInvalidValue = errors.New("invalid value, should be pointer to struct or slice")
	// ErrInvalidValueOfLength invalid values do not match length
	ErrInvalidValueOfLength = errors.New("invalid association values, length doesn't match")
)

Functions

func AutoMigrate added in v0.0.25

func AutoMigrate()

func Expr added in v0.0.30

func Expr(expr string, args ...interface{}) clause.Expr

func InitMySQL

func InitMySQL()

初始化数据库

func RegisterAutoMigrate added in v0.0.25

func RegisterAutoMigrate(value interface{})

func Transaction

func Transaction(ctx context.Context, fn funcType, opts ...*sql.TxOptions) (resp interface{}, err error)

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

func NewOrm

func NewOrm(ctx context.Context, dbName ...string) (db *DB)

func (*DB) AutoMigrate added in v0.0.24

func (db *DB) AutoMigrate(value ...interface{}) error

func (*DB) Begin

func (db *DB) Begin(opts ...*sql.TxOptions) *DB

func (*DB) Commit

func (db *DB) Commit() *DB

func (*DB) Count

func (db *DB) Count(count *int64) *DB

func (*DB) Create

func (db *DB) Create(value interface{}) (tx *DB)

func (*DB) Delete

func (db *DB) Delete(value interface{}, conds ...interface{}) *DB

func (*DB) Distinct

func (db *DB) Distinct(args ...interface{}) *DB

func (*DB) Error

func (db *DB) Error() error

func (*DB) Exec

func (db *DB) Exec(sql string, values ...interface{}) *DB

func (*DB) Find

func (db *DB) Find(dest interface{}, conds ...interface{}) *DB

func (*DB) First

func (db *DB) First(dest interface{}, conds ...interface{}) *DB

func (*DB) FirstOrCreate

func (db *DB) FirstOrCreate(dest interface{}, conds ...interface{}) *DB

func (*DB) GroupBy

func (db *DB) GroupBy(name string) *DB

func (*DB) Having

func (db *DB) Having(query interface{}, args ...interface{}) *DB

func (*DB) Joins

func (db *DB) Joins(query string, args ...interface{}) *DB

func (*DB) Last

func (db *DB) Last(dest interface{}, conds ...interface{}) *DB

func (*DB) Limit

func (db *DB) Limit(limit int) *DB

func (*DB) Model

func (db *DB) Model(value interface{}) *DB

func (*DB) Not

func (db *DB) Not(query interface{}, args ...interface{}) *DB

func (*DB) Offset

func (db *DB) Offset(offset int) *DB

func (*DB) Omit

func (db *DB) Omit(columns ...string) *DB

func (*DB) Or

func (db *DB) Or(query interface{}, args ...interface{}) *DB

func (*DB) OrderBy

func (db *DB) OrderBy(value interface{}) *DB

func (*DB) Pluck

func (db *DB) Pluck(column string, dest interface{}) *DB

func (*DB) Raw

func (db *DB) Raw(sql string, values ...interface{}) *DB

func (*DB) Rollback

func (db *DB) Rollback() *DB

func (*DB) RowsAffected

func (db *DB) RowsAffected() int64

func (*DB) Save

func (db *DB) Save(value interface{}) (tx *DB)

func (*DB) Scopes

func (db *DB) Scopes(funcs ...func(*DB) *DB) *DB

func (*DB) Select

func (db *DB) Select(query interface{}, args ...interface{}) *DB

func (*DB) Table

func (db *DB) Table(name string, args ...interface{}) *DB

func (*DB) Take

func (db *DB) Take(dest interface{}, conds ...interface{}) *DB

func (*DB) Update

func (db *DB) Update(column string, value interface{}) *DB

func (*DB) UpdateColumn

func (db *DB) UpdateColumn(column string, value interface{}) *DB

func (*DB) UpdateColumns

func (db *DB) UpdateColumns(values interface{}) *DB

func (*DB) Updates

func (db *DB) Updates(values interface{}) *DB

func (*DB) Where

func (db *DB) Where(query interface{}, args ...interface{}) *DB

type Options

type Options struct {
	Dns          string
	MaxIdleConns int
	MaxOpenConns int
	Mode         string
}

type TxContext

type TxContext struct {
	context.Context
	// contains filtered or unexported fields
}

func NewTxContext

func NewTxContext(ctx context.Context, txId int64, opts ...*sql.TxOptions) *TxContext

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL