sharding

package
v2.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(mas []config.Mysql, sls []config.Mysql)

Types

type Mysql

type Mysql[T itf.ModelInterface] struct {
	// contains filtered or unexported fields
}

func NewMysql

func NewMysql[T itf.ModelInterface]() *Mysql[T]

func NewMysqlBy added in v2.2.1

func NewMysqlBy[T itf.ModelInterface](isMaster bool) *Mysql[T]

func (*Mysql[T]) AddSharding

func (m *Mysql[T]) AddSharding(key any) *Mysql[T]

func (*Mysql[T]) BatchInsert

func (m *Mysql[T]) BatchInsert(key any, batch *ds.Batch) (int64, error)

func (*Mysql[T]) BatchInsertCtx added in v2.1.0

func (m *Mysql[T]) BatchInsertCtx(ctx context.Context, key any, batch *ds.Batch) (int64, error)

func (*Mysql[T]) Count added in v2.0.8

func (m *Mysql[T]) Count(key any, table string, where ds.WhereInterface) (int64, error)

func (*Mysql[T]) CountCtx added in v2.1.0

func (m *Mysql[T]) CountCtx(ctx context.Context, key any, table string, where ds.WhereInterface) (int64, error)

func (*Mysql[T]) Delete

func (m *Mysql[T]) Delete(key any, del *ds.Delete) (int64, error)

func (*Mysql[T]) DeleteCtx added in v2.1.0

func (m *Mysql[T]) DeleteCtx(ctx context.Context, key any, del *ds.Delete) (int64, error)

func (*Mysql[T]) Exec

func (m *Mysql[T]) Exec(key any, statement string) error

func (*Mysql[T]) ExecCtx added in v2.1.0

func (m *Mysql[T]) ExecCtx(ctx context.Context, key any, statement string) error

func (*Mysql[T]) FetchAll

func (m *Mysql[T]) FetchAll(key any, table string, where meta.Where, model T) ([]T, error)

func (*Mysql[T]) FetchAllByWhere

func (m *Mysql[T]) FetchAllByWhere(key any, table string, where ds.WhereInterface, model T) ([]T, error)

func (*Mysql[T]) FetchAllByWhereCtx added in v2.1.0

func (m *Mysql[T]) FetchAllByWhereCtx(ctx context.Context, key any, table string, where ds.WhereInterface, model T) ([]T, error)

func (*Mysql[T]) FetchAllCtx added in v2.1.0

func (m *Mysql[T]) FetchAllCtx(ctx context.Context, key any, table string, where meta.Where, model T) ([]T, error)

func (*Mysql[T]) FetchPage

func (m *Mysql[T]) FetchPage(key any, table string, where meta.Where, model T, page, pageSize int, orders ...string) (*meta.Page[T], error)

func (*Mysql[T]) FetchPageBySelect added in v2.0.8

func (m *Mysql[T]) FetchPageBySelect(key any, sel *ds.Select, model T) (*meta.Page[T], error)

func (*Mysql[T]) FetchPageBySelectCtx added in v2.1.0

func (m *Mysql[T]) FetchPageBySelectCtx(ctx context.Context, key any, sel *ds.Select, model T) (*meta.Page[T], error)

func (*Mysql[T]) FetchPageByWhere

func (m *Mysql[T]) FetchPageByWhere(key any, table string, where ds.WhereInterface, model T, page, pageSize int, orders ...string) (*meta.Page[T], error)

func (*Mysql[T]) FetchPageByWhereCtx added in v2.1.0

func (m *Mysql[T]) FetchPageByWhereCtx(ctx context.Context, key any, table string, where ds.WhereInterface, model T, page, pageSize int, orders ...string) (*meta.Page[T], error)

func (*Mysql[T]) FetchPageCtx added in v2.1.0

func (m *Mysql[T]) FetchPageCtx(ctx context.Context, key any, table string, where meta.Where, model T, page, pageSize int, orders ...string) (*meta.Page[T], error)

func (*Mysql[T]) FetchRow

func (m *Mysql[T]) FetchRow(key any, table string, where meta.Where, model T) error

func (*Mysql[T]) FetchRowCtx added in v2.1.0

func (m *Mysql[T]) FetchRowCtx(ctx context.Context, key any, table string, where meta.Where, model T) error

func (*Mysql[T]) GetConnection

func (m *Mysql[T]) GetConnection(key int) *db.Mysql[T]

func (*Mysql[T]) GetShardingKey

func (m *Mysql[T]) GetShardingKey(key any) int

func (*Mysql[T]) Insert

func (m *Mysql[T]) Insert(key any, insert *ds.Insert) (int64, error)

func (*Mysql[T]) InsertCtx added in v2.1.0

func (m *Mysql[T]) InsertCtx(ctx context.Context, key any, insert *ds.Insert) (int64, error)

func (*Mysql[T]) LockRow added in v2.0.4

func (m *Mysql[T]) LockRow(key any, table string, where meta.Where, model T) error

func (*Mysql[T]) LockRowCtx added in v2.1.0

func (m *Mysql[T]) LockRowCtx(ctx context.Context, key any, table string, where meta.Where, model T) error

func (*Mysql[T]) Query

func (m *Mysql[T]) Query(key any, query string, model T, args ...any) ([]T, error)

func (*Mysql[T]) QueryCtx added in v2.1.0

func (m *Mysql[T]) QueryCtx(ctx context.Context, key any, query string, model T, args ...any) ([]T, error)

func (*Mysql[T]) Reset added in v2.2.1

func (m *Mysql[T]) Reset()

func (*Mysql[T]) Set added in v2.2.1

func (m *Mysql[T]) Set(isMaster bool, tx *Tx)

func (*Mysql[T]) SetTx added in v2.0.3

func (m *Mysql[T]) SetTx(tx *Tx)

func (*Mysql[T]) Transaction added in v2.0.3

func (m *Mysql[T]) Transaction(f func(tx *Tx) error) error

func (*Mysql[T]) TransactionCtx added in v2.1.0

func (m *Mysql[T]) TransactionCtx(ctx context.Context, f func(tx *Tx) error, opts *sql.TxOptions) error

func (*Mysql[T]) Update

func (m *Mysql[T]) Update(key any, update *ds.Update) (int64, error)

func (*Mysql[T]) UpdateCtx added in v2.1.0

func (m *Mysql[T]) UpdateCtx(ctx context.Context, key any, update *ds.Update) (int64, error)

type Tx added in v2.0.3

type Tx struct {
	*object.ObjNoCtx
	// contains filtered or unexported fields
}

func NewTx added in v2.0.3

func NewTx() *Tx

func NewTxBy added in v2.2.1

func NewTxBy(ctx object.CtxInterface) *Tx

func (*Tx) Add added in v2.0.3

func (t *Tx) Add(id int, tx *db.Tx)

func (*Tx) Commit added in v2.0.3

func (t *Tx) Commit()

func (*Tx) IsCompleted added in v2.0.3

func (t *Tx) IsCompleted() bool

func (*Tx) Reset added in v2.2.1

func (t *Tx) Reset()

func (*Tx) Rollback added in v2.0.3

func (t *Tx) Rollback()

Jump to

Keyboard shortcuts

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