ComposedQL is a query language that aims URI friendly queries for RESTful APIs.
- Composing data queries with efficient way
- Selecting only a subset of data
- Filtering sensitive information
- Creating authZ compatible API endpoints
- Improving caching and routing
- URI friendly queries
- High performance query parsing
- Exchangeable and human readable/writable structure
(work in progress)
- Fields represent object properties, resources or functions.
- Examples:
foo
- field~foo
- resourcefoo()
- function
- Examples:
- Commas are separators for fields or function arguments
- Examples;
foo,bar
- fields~foo(bar,baz)
- resource fieldsfoo(bar,baz)
- function arguments
- Examples;
- Dots are accessors for accessing nested fields or field functions
- Examples;
foo.bar
- nested field~foo(bar.baz)
- nested resource fieldfoo.bar()
- field functionfoo(bar).baz(qux)
- function chain~foo(bar).baz(qux)
- resource field chain
- Examples;
This repository provides composed query language parser and specifications.
npm install composedql
var cql = require('composedql');
Parses given composed query
cql.parse('user,location.city');
[ { name: 'user',
type: 'field',
source: 'user' },
{ name: 'location',
type: 'field',
source: 'location.city',
properties: [ { name: 'city', type: 'property' } ] } ]
cql.parse('user,~photo(profile,cover),~post(id,text).from(today)');
[ { name: 'user',
type: 'field',
source: 'user' },
{ name: 'photo',
type: 'resource',
source: '~photo(profile,cover)',
fields:
[ { name: 'profile',
type: 'field',
source: 'profile' },
{ name: 'cover',
type: 'field',
source: 'cover' } ] },
{ name: 'post',
type: 'resource',
source: '~post(id,text).from(today)',
fields:
[ { name: 'id',
type: 'field',
source: 'id' },
{ name: 'text',
type: 'field',
source: 'text' } ],
properties:
[ { name: 'from',
type: 'function',
args:
[ { name: 'today',
type: 'arg',
source: 'today' } ] } ] } ]
Licensed under The MIT License (MIT)
For the full copyright and license information, please view the LICENSE.txt file.