Documentation
¶
Overview ¶
Package query parses and applies safe, resource-defined PostgreSQL queries.
Index ¶
- func Apply(selectQuery *bun.SelectQuery, params Params, definition Definition) *bun.SelectQuery
- func ApplyPagination(selectQuery *bun.SelectQuery, params Params) *bun.SelectQuery
- func EscapeLike(value string) string
- type Definition
- type Field
- type Filter
- type Operator
- type Params
- type Sort
- type SortField
- type ValueType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
func Apply(selectQuery *bun.SelectQuery, params Params, definition Definition) *bun.SelectQuery
func ApplyPagination ¶
func ApplyPagination(selectQuery *bun.SelectQuery, params Params) *bun.SelectQuery
func EscapeLike ¶
Types ¶
type Definition ¶
type Definition struct {
Filters []Field
Searchable []string
Sortable []SortField
DefaultSort []Sort
DefaultPage int
DefaultPerPage int
MaxPerPage int
// MaxPage bounds the deepest requestable page. Offset pagination degrades
// with depth, and an unbounded page overflows the computed offset, so the
// zero value resolves to a finite default rather than no limit.
MaxPage int
// DisableTotalCount skips the per-request COUNT that backs Total and Pages.
// The count is a second scan of the filtered set on every list request.
DisableTotalCount bool
// SearchPredicate replaces the default case-insensitive contains search.
// The default cannot use an index; supply this to route search through
// pg_trgm, a tsvector column, or any other indexed strategy.
SearchPredicate func(*bun.SelectQuery, string) *bun.SelectQuery
}
func (Definition) Validate ¶
func (definition Definition) Validate() error
func (Definition) WithDefaults ¶
func (definition Definition) WithDefaults() Definition
Click to show internal directories.
Click to hide internal directories.