Post-Filters
Filters applied on a query result AFTER grouping, sorting and slicing.
Once a query returns some results, a post-filter can be applied on them to further restrict the number of matching results that are returned.
Post-filter expressions are processed in the V8 engine and NOT the query engine, using a jsep expression parser that has been augmented with a few extensions.
The filter expression is applied individually to each item in the result array (these items may be entire groups). Only those items for which the expression evaluates to a truthy value are passed through.
Important: jsep does not support object literals, only array literals. This may be fixed in a fork, maintained by RecallGraph, in the future.
Core JS Operators
Most of the following (non-mutating) standard operators are understood by jsep out of the box. A few are implemented using extensions. Regardless, they are all processed exactly as they would be processed in a normal JavaScript runtime
All non-mutating arithmetic operators (everything except increment and decrement)
Property accessors (including method calls)
Explicit (dot and bracket notation; using
thiskeyword to refer to current item in result array)Implicit (using implicit
thiscontext per item in a result array; method calls on thethisobject not accessible with this style)
Literals
All primitive types (except
Symbol)Array expressions (both literal and dynamic)
jsep Extensions
Some of the core JS operators listed above are actually implemented using extensions in jsep. Additionally, some useful operators that are not part of JS syntax are also supported for convenience.
Operators
=~- Regex Match. Filters on a regex pattern. The left operand must match the regex pattern given in the right operand for the filter to pass.=*- Glob Match. Filters on a glob pattern. The left operand must match the glob pattern given in the right operand for the filter to pass.
Namespaced Helpers
Apart from the regular operators and member functions that the built-in data types support, it is often handy to be able to invoke Math functions or methods from the lodash utility. jsep has been extended to provide access to these functions and some more, using named object literals that represent these modules. The available namespaces are listed below, along with special shortcuts, if any, to access them.
$Math - The Math Global Object
Math Global ObjectAll methods and properties of the Math global object are available under this namespace. An example usage may be:
$_ - The lodash utility module
lodash utility moduleAll methods and properties of the lodash utility module are available under this namespace. In addition to being referred to by the $_ namespace handle, this is also the default namespace under which methods are searched when they are invoked as standalone functions, without a property dereference. For example:
Note that the default namespace is searched only when a function call is made, and not when just referencing the function as a member. In that case, the member will be searched for under the this context of the current object under iteration of the result array.
$RG - The RecallGraph Namespace for Special Functions
This namespace is reserved for some special functions defined by RecallGraph. The supported methods are:
This method returns the type of the parameter passed to it. Its behavior is identical to the JavaScript typeof operator. For example:
This method performs a glob match test on str against the provided pattern. For example:
This method performs a regex match test on str against the provided pattern. For example:
For more examples, take a look at the test cases defined in helpers.test.js.
Last updated