FIQL Query Builder
Overview
Feed Item Query Language (FIQL) is a simple, URI-friendly query language for filtering entries of web feeds.
This module provides the utility to generate valid FIQL query strings by using a JSON objects or the custom classes provided.
Installation
$ npm install fiql-query-builder
Usage
FIQL query strings can be produced by supplying a JSON object, or using the Node classes provided.
JSON to FIQL
// var json = ...; // Using require()var fiqlQueryBuilder = ;fiqlQueryBuilder; // Using ES6 import;;
Basic Operators
Object Key | Children | Description |
---|---|---|
custom_operator |
|
Define a custom basic operator |
equals |
|
Produces an equality operator (== ) |
not_equals |
|
Produces an inequality operator (!= ) |
less_than |
|
Produces an less than operator (=lt= ) |
less_than_or_equal |
|
Produces an less than or equal operator (=le= ) |
greater_than |
|
Produces an greater operator (=gt= ) |
greater_than_or_equal |
|
Produces an greater than or equal operator (=ge= ) |
in |
|
Produces an in operator (in ) |
out |
|
Produces an out operator (out ) |
Boolean Expressions
Object Key | Children | Description |
---|---|---|
custom_expression |
|
Define a custom boolean expression |
and |
|
Combines child array with an and operator (; ) |
or |
|
Combines child array with an or operator (, ) |
Grouping
Object Key | Children | Description |
---|---|---|
group |
|
Wraps an expression in parentheses |
Node to FIQL
// var node = ... // Using require()var fiqlQueryBuilder = ;fiqlQueryBuilder; // Using ES6 import;;
LeafNode(value)
The query param is built by traversing the object tree recursively, so a LeafNode
is used to represent a primitive value.
Param | Type | Description |
---|---|---|
value | string |
The string value |
OpNode(selector, operator, args)
A generic operator
Param | Type | Description |
---|---|---|
selector | LeafNode |
The left-hand side of the operator |
operator | string |
The custom operator |
args | GroupNode | LeafNode | ExpNode | OpNode |
The child node for operator (right-hand side) |
Subclasses
Standard operator classes have been provided, and can be instantiated using ClassName(selector, args)
.
- Equality (
==
) :EqNode
- Inequality (
!=
) :NeqNode
- Less than (
=lt=
) :LtNode
- Less than or equal to (
=le=
) :LeNode
- Greater than (
=gt=
) :GtNode
- Greater than or equals to (
=ge=
) :GeNode
- In (
=in=
) :InNode
- Not in (
=out=
) :NotInNode
ExpNode(operator, children)
A generic boolean expression
Param | Type | Description |
---|---|---|
operator | string |
The custom operator |
children | Node[] |
The child nodes for the expression |
Subclasses
Standard boolean expression classes have been provided, and can be instantiated using ClassName(children)
.
- And (
;
) :AndNode
- Or (
,
) :OrNode
GroupNode(exp)
Used to wrap parentheses around a boolean expression.
Param | Type | Description |
---|---|---|
exp | ExpNode |
The boolean expression to wrap parentheses around |
Examples
JSON to FIQL
Example standard basic operator
var eqJson = ;// eqJson = foo==bar
Example custom basic operator
var customOperatorJson = ;// customOperatorJson equals: foo¬bar
Example standard boolean expression
var andJson = ;// andJson equals: foo==bar;baz!=qux
Example custom boolean expression
var customExpressionJson = ;// customExpressionJson equals: foo==bar*baz!=qux
Example grouping and nested arguments
var groupJson = ;// groupJson equals: k==(foo=lt=bar,baz!=qux)
Node to FIQL
Example standard basic operator
var eqNode = ;// eqNode = foo==bar
Example custom basic operator
var customOperatorNode = ;// customOperatorNode equals: foo¬bar
Example standard boolean expression
var andNode = ;// andNode equals: foo==bar;baz!=qux
Example custom boolean expression
var customExpressionNode = ;// customExpressionNode equals: foo==bar*baz!=qux
Example grouping and nested arguments
var groupNode = ;// groupNode equals: k==(foo=lt=bar,baz!=qux)
License
This project is licensed under MIT License