Calypso Query Language
- Use a SQL-like query language over any queryable data store.
- Parser & AST provided.
- Used by calypso and other projects.
npm install caql
The Calypso Query Language (CaQL) has support for field selection, field aliases, filters, and ordering.
select [fields | *]
Select is optional. If not provided, drivers should treat it as an unbounded field selection ('*').
Fields can contain letters, numbers, underscores, and hyphens.
Deep field selections are allowed.
Fields can be escaped using brackets as delimiters.
select [date of birth], age, name
Fields can also be aliased.
select title as t, author as a
Starts a filter.
select title where author="Kurt Vonnegut"
CaQL supports the following comparison expressions:
select * where name = "Kevin"
select * where name != "Rose"
select * where age > 30
Greater than or equal to:
select * where age >= 30
select * where price < 10
Less than or equal to:
select * where price <= 10
To negate comparisons, use
select * where not age > 30
Use CaQL to discover whether an object has a property.
select * where price is missing
select * where price is not missing
select * where name contains "Kevin"
select * where name like "%evi%"
The percent symbol (
%) acts as a wildcard character matching zero or more characters.
like operator can be negated with
select * where name not like "%evi%"
The location expression supports a distance along with a latitude, longitude pair.
select * where location within 30 of 90.2342, 30.23432
Note: Not all drivers may support this option.
CaQL has support for conjunctions using the keyword
select * where name="Kevin" and age=31
CaQL has support for disjunctions, as well, using
select * where name="Kevin" or name="Matt"
Results can be sorted. A direction can be added. Ascending (
asc) is used by default. Descending (
desc) must be explicit.
select name, age order by age desc, name asc