gplus

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2023 License: Apache-2.0 Imports: 7 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete[T any](q *Query[T]) *gorm.DB

func DeleteById

func DeleteById[T any](id any) *gorm.DB

func DeleteByIds

func DeleteByIds[T any](ids any) *gorm.DB

func Init

func Init(db *gorm.DB)

func Insert

func Insert[T any](entity *T) *gorm.DB

func InsertBatch

func InsertBatch[T any](entities []*T) *gorm.DB

func InsertBatchSize

func InsertBatchSize[T any](entities []*T, batchSize int) *gorm.DB

func SelectById

func SelectById[T any](id any) (*T, *gorm.DB)

func SelectByIds

func SelectByIds[T any](ids any) ([]*T, *gorm.DB)

func SelectCount

func SelectCount[T any](q *Query[T]) (int64, *gorm.DB)

func SelectList

func SelectList[T any](q *Query[T]) ([]*T, *gorm.DB)

func SelectListModel

func SelectListModel[T any, R any](q *Query[T]) ([]*R, *gorm.DB)

func SelectOne

func SelectOne[T any](q *Query[T]) (*T, *gorm.DB)

func Update

func Update[T any](q *Query[T]) *gorm.DB

func UpdateById

func UpdateById[T any](entity *T, id any) *gorm.DB

Types

type CommonDao

type CommonDao[T any] struct{}

func NewCommonDao added in v0.0.10

func NewCommonDao[T any](pk string) *CommonDao[T]

func (CommonDao[T]) Count

func (service CommonDao[T]) Count(q *Query[T]) (int64, *gorm.DB)

func (CommonDao[T]) CountAll

func (service CommonDao[T]) CountAll() (int64, *gorm.DB)

func (CommonDao[T]) Db added in v0.0.10

func (service CommonDao[T]) Db() *gorm.DB

func (CommonDao[T]) GetById

func (service CommonDao[T]) GetById(id any) (*T, *gorm.DB)

func (CommonDao[T]) GetOne

func (service CommonDao[T]) GetOne(q *Query[T]) (*T, *gorm.DB)

func (CommonDao[T]) List

func (service CommonDao[T]) List(q *Query[T]) ([]*T, *gorm.DB)

func (CommonDao[T]) ListAll

func (service CommonDao[T]) ListAll() ([]*T, *gorm.DB)

func (CommonDao[T]) ListByIds

func (service CommonDao[T]) ListByIds(ids []any) ([]*T, *gorm.DB)

func (CommonDao[T]) Page

func (service CommonDao[T]) Page(page *Page[T], q *Query[T]) (*Page[T], *gorm.DB)

func (CommonDao[T]) PageAll

func (service CommonDao[T]) PageAll(page *Page[T]) (*Page[T], *gorm.DB)

func (CommonDao[T]) Remove

func (service CommonDao[T]) Remove(q *Query[T]) *gorm.DB

func (CommonDao[T]) RemoveById

func (service CommonDao[T]) RemoveById(id any) *gorm.DB

func (CommonDao[T]) RemoveByIds

func (service CommonDao[T]) RemoveByIds(ids []any) *gorm.DB

func (CommonDao[T]) Save

func (service CommonDao[T]) Save(entity *T) *gorm.DB

func (CommonDao[T]) SaveBatch

func (service CommonDao[T]) SaveBatch(entities []*T) *gorm.DB

func (CommonDao[T]) SaveBatchSize

func (service CommonDao[T]) SaveBatchSize(entities []*T, batchSize int) *gorm.DB

func (CommonDao[T]) Update

func (service CommonDao[T]) Update(q *Query[T]) *gorm.DB

func (CommonDao[T]) UpdateById

func (service CommonDao[T]) UpdateById(entity *T, id any) *gorm.DB

type Page

type Page[T any] struct {
	Current int
	Size    int
	Total   int64
	Records []*T
}

func NewPage

func NewPage[T any](current, size int) *Page[T]

func SelectPage

func SelectPage[T any](page *Page[T], q *Query[T]) (*Page[T], *gorm.DB)

func SelectPageModel

func SelectPageModel[T any, R any](page *Page[R], q *Query[T]) (*Page[R], *gorm.DB)

type Query

type Query[T any] struct {
	SelectColumns     []string
	DistinctColumns   []string
	QueryBuilder      strings.Builder
	OrBracketBuilder  strings.Builder
	OrBracketArgs     []any
	AndBracketBuilder strings.Builder
	AndBracketArgs    []any
	QueryArgs         []any
	OrderBuilder      strings.Builder
	GroupBuilder      strings.Builder
	HavingBuilder     strings.Builder
	HavingArgs        []any
	LastCond          string
	UpdateMap         map[string]any
}

func NewQuery

func NewQuery[T any]() *Query[T]

func (*Query[T]) And

func (q *Query[T]) And() *Query[T]

func (*Query[T]) AndBracket

func (q *Query[T]) AndBracket(bracketQuery *Query[T]) *Query[T]

func (*Query[T]) Between

func (q *Query[T]) Between(column string, start, end any) *Query[T]

func (*Query[T]) Distinct

func (q *Query[T]) Distinct(column ...string) *Query[T]

func (*Query[T]) Eq

func (q *Query[T]) Eq(column string, val any) *Query[T]

func (*Query[T]) Ge

func (q *Query[T]) Ge(column string, val any) *Query[T]

func (*Query[T]) Group

func (q *Query[T]) Group(columns ...string) *Query[T]

func (*Query[T]) Gt

func (q *Query[T]) Gt(column string, val any) *Query[T]

func (*Query[T]) Having

func (q *Query[T]) Having(having string, args ...any) *Query[T]

func (*Query[T]) In

func (q *Query[T]) In(column string, val any) *Query[T]

func (*Query[T]) IsNotNull

func (q *Query[T]) IsNotNull(column string) *Query[T]

func (*Query[T]) IsNull

func (q *Query[T]) IsNull(column string) *Query[T]

func (*Query[T]) Le

func (q *Query[T]) Le(column string, val any) *Query[T]

func (*Query[T]) Like

func (q *Query[T]) Like(column string, val any) *Query[T]

func (*Query[T]) LikeLeft

func (q *Query[T]) LikeLeft(column string, val any) *Query[T]

func (*Query[T]) LikeRight

func (q *Query[T]) LikeRight(column string, val any) *Query[T]

func (*Query[T]) Lt

func (q *Query[T]) Lt(column string, val any) *Query[T]

func (*Query[T]) Ne

func (q *Query[T]) Ne(column string, val any) *Query[T]

func (*Query[T]) NotBetween

func (q *Query[T]) NotBetween(column string, start, end any) *Query[T]

func (*Query[T]) NotIn

func (q *Query[T]) NotIn(column string, val any) *Query[T]

func (*Query[T]) NotLike

func (q *Query[T]) NotLike(column string, val any) *Query[T]

func (*Query[T]) Or

func (q *Query[T]) Or() *Query[T]

func (*Query[T]) OrBracket

func (q *Query[T]) OrBracket(bracketQuery *Query[T]) *Query[T]

func (*Query[T]) OrderByAsc

func (q *Query[T]) OrderByAsc(columns ...string) *Query[T]

func (*Query[T]) OrderByDesc

func (q *Query[T]) OrderByDesc(columns ...string) *Query[T]

func (*Query[T]) Select

func (q *Query[T]) Select(columns ...string) *Query[T]

func (*Query[T]) Set

func (q *Query[T]) Set(column string, val any) *Query[T]

Jump to

Keyboard shortcuts

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