Codex ORM
![Slack Status](https://codex-community-slackin.herokuapp.com/badge.svg)
Build a graph and query it.
Powered by Neo4j 3, Bolt, and cypher-stream.
Install
npm install --save codex-orm
Example Usage
Creating a Tree with Access Control
'use strict';
var codex = require('codex-orm');
var R = require('ramda');
var saveTo = R.curry((target, x) =>
x.save(target)
);
var adopt = R.curry((parent, child) =>
parent.addChild(child)
);
var create = R.curry((type, properties) =>
new codex.Graph.Node(type, properties)
);
var tx = new codex.db.Transaction();
var childCount = 5;
var save = R.map(saveTo(tx));
var make = R.compose(save, create);
var parent = make('Parent', {});
var children = R.times(i =>
make('Child', { name: `Child ${i}`, i }),
childCount
);
children.map(adopt(parent)).map(save);
children.map(child => R.times(
i => make('Grand Child', { name: `Grand Child ${i}`, i })
.map(adopt(child))
.map(save),
childCount
));
var bob = new codex.Graph.User({ name: 'Bob' }).save(tx);
var sue = new codex.Graph.User({ name: 'Sue' }).save(tx);
tx.concat(bob.grantAccessTo(parent));
tx.concat(sue.grantAccessTo(children[3]));
tx.concat(parent.findRelated('Child', { accessor: sue }));
tx.concat(parent.findRelated('Child', { accessor: bob }));
tx.commit();
![The resulting graph](/example-graph.png)
The resulting graph.
Check the tests for more examples.