jsonQL Reference ~~~~~~~~~~~~~~~~ jsonQL is a language for querying data that can be represented in JSON. Abstractly, a jsonQL query operates on collection of JSON objects that conform to :doc:`pjson` semantics. More concretely, jsonQL works with a Vesper datastore, which provides a logical mapping between objects in a backend datastore to a collection of JSON objects (for example, each object might correspond to a row in table, with a property for each column). A jsonQL query operates on that mapping in a manner similar to a SQL query except that instead of returning rows it returns JSON data structures based on the pattern specified in the query. Unless otherwise specified, the example queries here are based on the example datastore found in the :doc:`tutorial`. You can cut and paste or you can run the admin tool on the sample store. .. raw:: html
.. code-block:: python >>> from vesper import app >>> model1 = app.createStore( ... '''[ ... { ... "type": "post", ... "id": "post1", ... "contents": "a post", ... "author": "@user:1" ... }, ... { ... "contents": "a comment", ... "type": "comment", ... "id": "comment1", ... "parent": "@post1", ... "author": "@user:2" ... }, ... { ... "author": "@user:1", ... "type": "comment", ... "id": "comment2", ... "parent": "@comment1", ... "contents": "a reply" ... }, ... { ... "author": "@user:1", ... "type": "comment", ... "id": "comment3", ... "parent": "@comment4", ... "contents": "different parent" ... }, ... { ... "displayname": "abbey aardvaark", ... "type": "user", ... "id": "user:1", ... "email": [ ... "abbey@aardvaark.com", ... "abbey_aardvaak@gmail.com" ... ] ... }, ... { ... "displayname": "billy billygoat", ... "type": "user", ... "id": "user:2" ... } ... ]''') Basic Grammar ============= Below is simplifed representation of the JQL grammar (the formal grammar can be found :doc:`here