Datastore query language.
npm install @travetto/model-query-languageInstall: @travetto/model-query-language
``bash
npm install @travetto/model-query-language
yarn add @travetto/model-query-language
`
This module provides a textual query language for the Data Model Querying interface. The language itself is fairly simple, boolean logic, with parenthetical support.The operators supported are:
* <, <= - Less than, and less than or equal to>
* , >= - Greater than, and greater than or equal to!=
* , == - Not equal to, and equal to~
* - Matches regular expression, supports the i flag to trigger case insensitive searches!
* , not - Negates a clausein
* , not-in - Supports checking if a field is in a list of literal valuesand
* , && - Intersection of clausesor
* , || - Union of clauses
All sub fields are dot separated for access, e.g. user.address.city.A query language version of the previous query could look like:
Code: Query language with boolean checks and exists check
`sql`
not (age < 35) and contact != null
A more complex query would look like:
Code: Query language with more complex needs
`sql`
user.role in ['admin', 'root'] && (user.address.state == 'VA' || user.address.city == 'Springfield')
or as /patterns/. The latter allows for the case insensitive modifier: /pattern/i`. Supporting the insensitive flag is up to the underlying model implementation.