Documentation
¶
Overview ¶
Package query parses and checks the list query language (where, order_by) against a collection's schema, producing backend-neutral storage conditions. Client input never reaches the database as-is: only the operators below exist, and every field and value is checked.
Index ¶
- Constants
- func Cursorable(sort []storage.SortField, fields map[string]registry.Field) (ok bool, field string)
- func EncodeCursor(sort []storage.SortField, doc storage.Document) string
- func ParseCount(s string) (bool, error)
- func ParseCursor(cursor string, sort []storage.SortField, fields map[string]registry.Field) (storage.Filter, error)
- func ParseOrderBy(s string, fields map[string]registry.Field) ([]storage.SortField, error)
- func ParseWhere(where string, fields map[string]registry.Field) (storage.Filter, error)
- type Error
- type Errors
Constants ¶
const ( MaxWhereBytes = 4096 // size of the raw where parameter MaxConditions = 32 // operator clauses in where MaxTextLen = 256 // value length for text operators MaxLikeWildcards = 4 // % and _ in a $like / $ilike pattern MaxSortFields = 8 // fields in order_by MaxGroupDepth = 4 // nesting of $or / $and groups )
Limits on query complexity.
Variables ¶
This section is empty.
Functions ¶
func Cursorable ¶ added in v0.5.0
Cursorable reports whether a cursor can follow the sort. When it can't, field names the sort field that stops it.
func EncodeCursor ¶ added in v0.5.0
EncodeCursor makes the cursor that continues after doc in this sort. The sort must be Cursorable.
func ParseCount ¶
ParseCount parses the count parameter ("", "true" or "false").
func ParseCursor ¶ added in v0.5.0
func ParseCursor(cursor string, sort []storage.SortField, fields map[string]registry.Field) (storage.Filter, error)
ParseCursor checks a cursor against the sort it is used with, and returns the condition that selects the documents after its position. Anything else is reported as an error on the `after` parameter.
func ParseOrderBy ¶
ParseOrderBy parses a comma-separated field list with an optional "-" prefix for descending order. An "id" tiebreaker is appended unless id is already present, so pagination is stable. Empty means id ascending.
func ParseWhere ¶
ParseWhere parses the where parameter (a JSON object) into a filter tree: the object's keys combine with AND, and "$or" / "$and" take an array of where objects. An empty string or object means no filter (nil). Keys are processed in sorted order, so the result is deterministic.