sm

seraph_model

thin model layer for seraph/neo4j

Showing:

Popularity

Downloads/wk

7

Maintenance

No Maintenance Data Available

Package

Dependencies

2

Size (min+gzip)

6.3KB

License

BSD-2-Clause

Type Definitions

Tree-Shakeable

No?

Categories

Readme

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

### Quick example
var db = require('seraph')('http://localhost:7474')
var model = require('seraph_model');

var User = model(db, 'user');

User.save({ name: 'Jon', city: 'Bergen' }, function(err, saved) {
  if (err) throw err;

  User.findAll(function(err, allUsers) {
    // allUsers -> [{ name: 'Jon', city: 'Bergen', id: 0 }]
  });
  User.where({ city: 'Bergen' }, function(err, usersFromBergen) {
    // usersFromBergen -> all user objects with city == bergen
  });
})

Documentation

## Creating a new model {#create}

__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.

## model.save(object(s), callback(err, savedObject)) {#save}

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

## model.findAll(callback(err, allOfTheseModels))

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

## model.where(callback(err, matchingModels))

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.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100