query

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Limit

func Limit[V TableModel](val int) limit[V]

func Offset

func Offset[V TableModel](val int) offset[V]

func OrderBy

func OrderBy[V TableModel](val string) orderBy[V]

func Projection added in v0.1.2

func Projection[V TableModel](list ...string) projection[V]

Types

type Field

type Field[V TableModel] interface {
	Do(db *gorm.DB) *gorm.DB
	DoUpdate(UpdateReq)
	Table() V
}

func CustomQuery

func CustomQuery[V TableModel](or bool, sql string, args ...any) Field[V]

type Operator

type Operator[V TableModel] struct {
}

func NewOperator

func NewOperator[V TableModel]() Operator[V]

func (Operator[V]) Count added in v0.1.2

func (o Operator[V]) Count(ctx context.Context, db *gorm.DB, finds ...Field[V]) (int64, error)

func (Operator[V]) CustomQuery added in v0.1.2

func (d Operator[V]) CustomQuery(or bool, sql string, args ...any) Field[V]

func (Operator[V]) Delete

func (d Operator[V]) Delete(ctx context.Context, db *gorm.DB, finds ...Field[V]) error

func (Operator[V]) Find

func (o Operator[V]) Find(ctx context.Context, db *gorm.DB, finds ...Field[V]) ([]*V, error)

func (Operator[V]) FindAndCount added in v0.1.2

func (o Operator[V]) FindAndCount(ctx context.Context, db *gorm.DB, finds ...Field[V]) ([]*V, int64, error)

func (Operator[V]) Get

func (o Operator[V]) Get(ctx context.Context, db *gorm.DB, finds ...Field[V]) (*V, error)

func (Operator[V]) Insert

func (o Operator[V]) Insert(ctx context.Context, db *gorm.DB, val *V) error

func (Operator[V]) Limit added in v0.1.1

func (d Operator[V]) Limit(l int) Field[V]

func (Operator[V]) Offset added in v0.1.1

func (d Operator[V]) Offset(o int) Field[V]

func (Operator[V]) OrderBy added in v0.1.1

func (d Operator[V]) OrderBy(ob string) Field[V]

func (Operator[V]) Projection added in v0.1.2

func (d Operator[V]) Projection(list ...string) Field[V]

func (Operator[V]) Update

func (d Operator[V]) Update(ctx context.Context, db *gorm.DB, finds []Field[V], updates ...Field[V]) error

type Opt

type Opt struct {
	Or        orCond
	CheckZero zeroCond
}

type TableModel

type TableModel interface {
	TableName() string
}

type UpdateReq

type UpdateReq map[string]any

type WithOpt

type WithOpt func(o *Opt)

func CheckZero

func CheckZero() WithOpt

CheckZero if add this opt, cond will check the zero value ,it means `where id = 0` will not exec and it will be just return

func Or

func Or() WithOpt

Jump to

Keyboard shortcuts

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