Documentation
¶
Overview ¶
Package filter ... Deprecated: use github.com/n-r-w/squirrel
Index ¶
- Constants
- Variables
- func NewInCond[T any](sqlName string, values []T) *inCond
- func NewSelectBuilder(opts ...option) (sq.SelectBuilder, error)
- func WithIn[T any](sqlName string, values []T) option
- func WithInConds(conds ...inCond) option
- func WithOrders(aliases map[int]string, orders ...OrderCond) option
- func WithPKField(pkfield string) option
- func WithPaginator(paginator Paginator) option
- func WithSearch(search string, fields ...string) option
- func WithoutOrder() option
- type OrderCond
- type OrderType
- type Paginator
Constants ¶
const ( // ASC ascending sort order ASC = OrderType(0) // DESC descending sort order DESC = OrderType(1) )
Variables ¶
var ( // ErrOrderAliasNotFound SQL alias for orderID was not found ErrOrderAliasNotFound = errors.New("sql alias for orderID not found") // ErrUnknownOrderType unknown sort type ErrUnknownOrderType = errors.New("unknown order type") )
Functions ¶
func NewSelectBuilder ¶
func NewSelectBuilder(opts ...option) (sq.SelectBuilder, error)
NewSelectBuilder returns squirrel SelectBuilder built from provided opts Deprecated: use github.com/n-r-w/squirrel
func WithInConds ¶
func WithInConds(conds ...inCond) option
WithInConds adds IN conditions. Useful in cases where you need to customize the created InCond condition
func WithOrders ¶
WithOrders adds sorting conditions (orders). Aliases for mapping orderID from OrderCond and sqlName are passed in aliases parameter. Duplicate sort conditions are ignored
func WithPKField ¶
func WithPKField(pkfield string) option
WithPKField specifies the name for PK. Used in cases where PK name differs from default "id". Can specify a composite key in the format: (field1, field2)
func WithPaginator ¶
func WithPaginator(paginator Paginator) option
WithPaginator adds pagination based on Paginator. If a service paginator is provided, pagination will be performed by the last PK value with condition pkField > lastID If a frontend paginator is provided, pagination will be performed by limit and offset. Panics when attempting to add paginator again
func WithSearch ¶
WithSearch adds search condition for all provided fields
Types ¶
type OrderCond ¶
type OrderCond struct { Type OrderType // contains filtered or unexported fields }
OrderCond sort condition
type Paginator ¶
type Paginator struct {
// contains filtered or unexported fields
}
Paginator Data pagination
func NewFrontPaginator ¶
NewFrontPaginator returns a frontend type paginator
func NewServicePaginator ¶
NewServicePaginator returns a service type paginator