thin model layer for seraph/neo4j

seraph_model provides some convenient functions for storing and retrieving typed nodes from a neo4j database. It is intended to work with seraph.

var db = require('seraph')('http://localhost:7474')
var model = require('seraph_model');
var User = model(db, 'user');{ name: 'Jon', city: 'Bergen' }, function(errsaved) {
  if (err) throw err;
  User.findAll(function(errallUsers) {
    // allUsers -> [{ name: 'Jon', city: 'Bergen', id: 0 }] 
  User.where({ city: 'Bergen' }, function(errusersFromBergen) {
    // usersFromBergen -> all user objects with city == bergen 


__seraph_model(seraphDbObject, modelTypeName)

You can create a new model by calling the function returned by requiring seraph_model.

It works by indexing each object under a nodes index. Each different model is simply an item in that index, with all of the instances of that model attached to it.

Saves or updates an object in the database. This is a composition of the and seraph.index calls. The object returned is given an ID. See for more information and an example (they are operationally identical).

Finds all of the objects that were saved with this type.

This is a operationally similar to seraph.find, but is restricted to searching for other objects indexed as this kind of model. See the quick example for an example of this in action.