mysql

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EqualPredicate              = Predicate("=")
	NotEqualPredicate           = Predicate("<>")
	GreaterThanPredicate        = Predicate(">")
	GreaterThanOrEqualPredicate = Predicate(">=")
	SmallerThanPredicate        = Predicate("<")
	SmallerThanOrEqualPredicate = Predicate("<=")
	InPredicate                 = Predicate("in")
	NotInPredicate              = Predicate("not in")
	AndPredicate                = Predicate("and")
	OrPredicate                 = Predicate("or")
	LikePredicate               = Predicate("LIKE")
)

Functions

This section is empty.

Types

type ModelQueryBuilder added in v0.0.10

type ModelQueryBuilder[T interface{}] struct {
	// contains filtered or unexported fields
}

func (*ModelQueryBuilder[T]) AddOrder added in v0.0.10

func (qb *ModelQueryBuilder[T]) AddOrder(attr string, asc bool) *ModelQueryBuilder[T]

func (*ModelQueryBuilder[T]) AddOrder2 added in v0.0.10

func (qb *ModelQueryBuilder[T]) AddOrder2(attr string, order model.OrderType) *ModelQueryBuilder[T]

func (*ModelQueryBuilder[T]) AddOrderByOpt added in v0.0.10

func (qb *ModelQueryBuilder[T]) AddOrderByOpt(w *OrderOption) *ModelQueryBuilder[T]

func (*ModelQueryBuilder[T]) AddWhere added in v0.0.10

func (qb *ModelQueryBuilder[T]) AddWhere(attr string, value interface{}, predicate Predicate) *ModelQueryBuilder[T]

func (*ModelQueryBuilder[T]) AddWhereAnd added in v0.0.10

func (qb *ModelQueryBuilder[T]) AddWhereAnd(value interface{}) *ModelQueryBuilder[T]

func (*ModelQueryBuilder[T]) AddWhereByOpt added in v0.0.10

func (qb *ModelQueryBuilder[T]) AddWhereByOpt(w *WhereOption) *ModelQueryBuilder[T]

func (*ModelQueryBuilder[T]) AddWhereLogic added in v0.0.10

func (qb *ModelQueryBuilder[T]) AddWhereLogic(value interface{}, logicPredicate Predicate) *ModelQueryBuilder[T]

or/and logic

func (*ModelQueryBuilder[T]) AddWhereOr added in v0.0.10

func (qb *ModelQueryBuilder[T]) AddWhereOr(value interface{}) *ModelQueryBuilder[T]

func (*ModelQueryBuilder[T]) BuildQuery added in v0.0.10

func (qb *ModelQueryBuilder[T]) BuildQuery() *map[string]interface{}

func (*ModelQueryBuilder[T]) ClearOrders added in v0.0.10

func (qb *ModelQueryBuilder[T]) ClearOrders() *ModelQueryBuilder[T]

func (*ModelQueryBuilder[T]) ClearWheres added in v0.0.10

func (qb *ModelQueryBuilder[T]) ClearWheres() *ModelQueryBuilder[T]

func (*ModelQueryBuilder[T]) Count added in v0.0.10

func (qb *ModelQueryBuilder[T]) Count(db *gorm.DB) (int64, error)

func (*ModelQueryBuilder[T]) Delete added in v0.0.10

func (qb *ModelQueryBuilder[T]) Delete(db *gorm.DB) (err error)

func (*ModelQueryBuilder[T]) First added in v0.0.10

func (qb *ModelQueryBuilder[T]) First(db *gorm.DB) (*T, error)

func (*ModelQueryBuilder[T]) Limit added in v0.0.10

func (qb *ModelQueryBuilder[T]) Limit(limit int64) *ModelQueryBuilder[T]

func (*ModelQueryBuilder[T]) Offset added in v0.0.10

func (qb *ModelQueryBuilder[T]) Offset(offset int64) *ModelQueryBuilder[T]

func (*ModelQueryBuilder[T]) OrderById added in v0.0.10

func (qb *ModelQueryBuilder[T]) OrderById(asc bool) *ModelQueryBuilder[T]

func (*ModelQueryBuilder[T]) QueryAll added in v0.0.10

func (qb *ModelQueryBuilder[T]) QueryAll(db *gorm.DB) ([]T, error)

func (*ModelQueryBuilder[T]) QueryOne added in v0.0.10

func (qb *ModelQueryBuilder[T]) QueryOne(db *gorm.DB) (*T, error)

func (*ModelQueryBuilder[T]) Updates added in v0.0.10

func (qb *ModelQueryBuilder[T]) Updates(db *gorm.DB, m map[string]interface{}) (err error)

func (*ModelQueryBuilder[T]) WhereId added in v0.0.10

func (qb *ModelQueryBuilder[T]) WhereId(p Predicate, value string) *ModelQueryBuilder[T]

func (*ModelQueryBuilder[T]) WhereIdIn added in v0.0.10

func (qb *ModelQueryBuilder[T]) WhereIdIn(value []string) *ModelQueryBuilder[T]

type MySqlConfig

type MySqlConfig struct {
	// MySqlHost       `yaml:",inline"` // inline has no effect for inherit, seems that yaml is ok
	Addr            string        `yaml:"addr"`
	Username        string        `yaml:"username"`
	Password        string        `yaml:"password"`
	Db              string        `yaml:"db"`
	MaxOpenConn     int           `yaml:"maxOpenConn"`
	MaxIdleConn     int           `yaml:"maxIdleConn"`
	ConnMaxLifeTime time.Duration `yaml:"connMaxLifeTime"`
}

type OrderOption added in v0.0.10

type OrderOption struct {
	Attr  string
	Order model.OrderType
}

type Predicate

type Predicate string

Predicate is a string that acts as a condition in the where clause

type Repo

type Repo interface {
	GetDb() *gorm.DB
	DbClose() error
	// contains filtered or unexported methods
}

func New

func New(cfg *MySqlConfig, logger *zap.Logger) (Repo, error)

type TracePlugin

type TracePlugin struct{}

func (*TracePlugin) Initialize

func (op *TracePlugin) Initialize(db *gorm.DB) (err error)

func (*TracePlugin) Name

func (op *TracePlugin) Name() string

type WhereOption added in v0.0.10

type WhereOption struct {
	Attr      string
	Predicate Predicate
	Value     interface{}
}

Jump to

Keyboard shortcuts

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