query

package
v0.0.0-...-6ef52c9 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Or  = 2
	And = 1
)

Variables

This section is empty.

Functions

func NewWhereBuilder

func NewWhereBuilder() *whereBuilder

Types

type AppIDB

type AppIDB struct {
	BunDB  bun.IDB
	GormDB *gorm.DB
}

type DB

type DB[T any] interface {
	RawExec(ctx context.Context, sqlQuery string, params []interface{}) (int64, error)
	RawQuery(ctx context.Context, sql string, params []interface{}, resultPtr interface{}) error
	Create(ctx context.Context, obj *T) (*T, error)
	CreateList(ctx context.Context, obj *[]T) (*[]T, error)
	Update(ctx context.Context, obj *T) (*T, error)
	UpdateList(ctx context.Context, obj *[]T) (*[]T, error)
	UpdateForce(ctx context.Context, obj *T) (*T, error)
	FindByPK(ctx context.Context, obj *T) (*T, error)
	Delete(ctx context.Context, obj *T) error
	DeleteList(ctx context.Context, obj *[]T) error
	DeleteWhere(ctx context.Context, whereCauses *[]WhereCause) error
	Count(ctx context.Context, whereObj *T) (int64, error)
	List(ctx context.Context, whereObj *T) (*[]T, error)
	ListWhere(ctx context.Context, whereCauses *[]WhereCause, limit *Limit, sortBy []string) (*[]T, error)
	QueryListWhere(ctx context.Context, whereCauses *[]WhereCause, limit *Limit, sortBy []string) (*[]T, int64, error)
	FirstWhere(ctx context.Context, whereCauses *[]WhereCause, sortBy []string) (*T, error)
	FindOneWhere(ctx context.Context, whereCauses *[]WhereCause) (*T, error)
	FindOne(ctx context.Context, whereObj *T) (*T, error)
	CountWhere(ctx context.Context, whereCauses *[]WhereCause) (int64, error)
}

type DBTx

type DBTx interface {
	WithTx(ctx context.Context, fn TxFn) error
}

type Limit

type Limit struct {
	Offset   int64 `json:"offset"`
	PageSize int64 `json:"pageSize"`
}

func NewLimit

func NewLimit(pageSize int64, offset int64) *Limit

type Sort

type Sort struct {
	SortBy        string `json:"sortBy"`
	SortDirection string `json:"sortDirection" example:"DESC" enums:"ASC,DESC"`
}

func NewSort

func NewSort(sortBy string, sortDirection string) *Sort

type TxFn

type TxFn func(ctx context.Context, appDB *AppIDB) error

type WhereCause

type WhereCause struct {
	Type  int
	Query string
	Args  []interface{}
}

Directories

Path Synopsis
bun

Jump to

Keyboard shortcuts

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