sjql

0.3.3 • Public • Published

SJQL - SynoGraph JSON Query Language

Query the SynoGraph using pure JSON objects, using the simple json-predicate syntax.

Usage

const path = require('path');
const SynoGraph = require('synograph').PersistentGraph;
SynoGraph.start(path.join(__dirname, 'data')).then(g => {
    require('./models')(g);
    console.log(JSON.stringify(jsonQuery(g, {
        query: [
            'text', // first step is always a string
            'posted', // mid-steps can either be a `string` or a `{of: String, filter: Object}` object
            {type: 'Person', filter: {
                path: '/name',
                op: 'starts',
                value: 'A'
            }} // either a `string` (of an ID), an `array<string>` (array of IDs) or a `{type: String, filter: Object, limit: Integer}` object.
        ],
        unique: true // default is true
    }), null, 2));
    // equivalent to:
    console.log(JSON.stringify(
        g.select('text').of('posted').ofAny(g.nodeTypes.Person.find(p => p.name.startsWith('A'))).get(), 
    null, 2));
});

Dependents (0)

Package Sidebar

Install

npm i sjql

Weekly Downloads

1

Version

0.3.3

License

MIT

Last publish

Collaborators

  • oakfang