View Source Loupe.Language.GetAst (Loupe v0.3.0)
Extracted AST structure from a get
query.
It uses a basic syntax like
get [quantifier?] [schema] where [predicates]
The quantifier is used to limit the queries result but can be ommited
defaulting to 1
. It supports the following:
- Positive integer;
1
,2
,10
etc... - Range:
10..20
, it limits the query to 10 records offsetting to the 10th record all
: Returns all the record matching
The schema needs to be an idenfifier (non-quoted alphanumeric) that matches
the definition's schemas/1
function.
The predicates are combination of boolean operators and operand for validation. See the module's type for every support operators but it can basically be a syntax like
get 5 User where (name = "John Doe") or (age > 18)
Link to this section Summary
Types
Composed bidings from nested querying
Valid boolean operators
Literial values usable in comparison
Valid comparison operands
Validation composed predicates
Query quantifier to limit the query result count
Range from one value to another
Reserved keywords
Link to this section Types
@type binding() :: {:binding, [binary()]}
Composed bidings from nested querying
@type boolean_operator() :: :or | :and
Valid boolean operators
Literial values usable in comparison
@type operand() :: := | :> | :>= | :< | :<= | :like | :in
Valid comparison operands
@type predicate() :: {boolean_operator(), predicate(), predicate()} | {operand(), binding(), literal()}
Validation composed predicates
Query quantifier to limit the query result count
Range from one value to another
@type reserved_keyword() :: :empty
Reserved keywords
@type t() :: %Loupe.Language.GetAst{ predicates: predicate(), quantifier: quantifier(), schema: binary() }
Link to this section Functions
Extracts bindings of an AST
@spec new(binding(), quantifier(), predicate()) :: t()
Instanciates the AST