Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

seraph

Package Overview
Dependencies
Maintainers
2
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seraph - npm Package Compare versions

Comparing version 0.14.5 to 0.15.0

bolt.js

2

lib/seraph.js

@@ -8,2 +8,3 @@ var naan = require('naan');

var Core = require('seraph-core');
var bolt = require('./bolt/seraph');

@@ -24,2 +25,3 @@ // Bind all functions of an object to a context (recursively)

function Seraph(options) {
if (options.bolt) return bolt(options);
var core = new Core(options);

@@ -26,0 +28,0 @@

7

package.json

@@ -11,3 +11,3 @@ {

"description": "A thin and familiar layer between node and neo4j's REST api.",
"version": "0.14.5",
"version": "0.15.0",
"repository": {

@@ -18,7 +18,5 @@ "url": "https://github.com/brikteknologier/seraph"

"test": "./node_modules/mocha/bin/mocha -R spec -t 10000 -s 2000",
"bolt-test": "TEST_MODE=bolt mocha -R spec -t 300000 -b test/root.js test/node.js test/relationship.js test/query.js test/label.js test/batching.js",
"quick-test": "USE_DIRTY_DATABASE=true NO_STOP=true ./node_modules/mocha/bin/mocha -R spec -t 3000 -s 2000"
},
"engines": {
"node": "~0.10.0"
},
"license": "MIT",

@@ -28,2 +26,3 @@ "dependencies": {

"naan": "~1.3.11",
"neo4j-driver": "^1.1.0-M01",
"request": "^2.36.0",

@@ -30,0 +29,0 @@ "seraph-core": "^1.1.0",

@@ -12,2 +12,3 @@ var db = require('./util/database').db();

assert(b.isBatch);
b.commit();
});

@@ -26,7 +27,8 @@

var ids = [];
db.batch(function(db) {
ids.push(db.read(users[0]));
ids.push(db.read(users[1]));
ids.push(db.read(users[2]));
}, function(err, results) {
var txn = db.batch();
ids.push(txn.read(users[0]));
ids.push(txn.read(users[1]));
ids.push(txn.read(users[2]));
txn.commit(function(err, results) {
assert(!err, err && err.message);
assert.deepEqual(results, users);

@@ -41,6 +43,6 @@ callback();

it('should perform a series of saves in a batch', function(done) {
db.batch(function(db) {
db.save({ newPerson: 'bob' });
db.save([ {newPerson: 'orange'}, {newPerson: 'cat'} ]);
}, function(err, result) {
var txn = db.batch();
txn.save({ newPerson: 'bob' });
txn.save([ {newPerson: 'orange'}, {newPerson: 'cat'} ]);
txn.commit(function(err, result) {
assert.equal(result[0].newPerson, 'bob');

@@ -57,6 +59,6 @@ assert.equal(result[1][0].newPerson, 'orange');

db.save({name:'Jon', age: 23}, function(err, user) {
db.batch(function(db) {
user.name = 'Jellybean';
db.save(user);
}, function(err, result) {
var txn = db.batch();
user.name = 'Jellybean';
txn.save(user);
txn.commit(function(err, result) {
db.read(user, function(err, user) {

@@ -72,5 +74,5 @@ assert(user.name == 'Jellybean');

db.save([{person:'First'},{person:'Second'}], function(err, users) {
db.batch(function(db) {
db.relate(users[0], 'knows', users[1], {testprop:'test'});
}, function(err, result) {
var txn = db.batch();
txn.relate(users[0], 'knows', users[1], {testprop:'test'});
txn.commit(function(err, result) {
db.relationships(users[0], function(err, rels) {

@@ -88,18 +90,2 @@ assert(rels.length == 1);

it('should index a node in a batch', function(done) {
var iname = uniqn();
db.save({person:'indexable'}, function(err, user) {
db.batch(function(db) {
db.legacyindex(iname, user, 'something', 'magical');
}, function(err, results) {
assert(!err);
db.legacyindex.read(iname, 'something', 'magical', function(err, node) {
assert(!err);
assert(node.person == 'indexable');
done();
});
});
});
});
it('should work in procedural mode', function(done) {

@@ -266,37 +252,2 @@ var txn = db.batch();

it('should support indexing', function(done) {
var txn = db.batch();
var idx = uniqn();
var person = txn.save({name:'Jon'});
txn.legacyindex(idx, person, 'thing', 'stuff');
txn.commit(function(err, results) {
assert(!err);
db.legacyindex.read(idx, 'thing', 'stuff', function(err, person1) {
assert(!err);
assert.deepEqual(person1, results[person]);
done();
});
});
});
it('should support indexing and index.readAsList', function(done) {
var txn = db.batch();
var idx = uniqn();
var person = txn.save({name:'Jon'});
txn.legacyindex(idx, person, 'thing', 'stuff');
txn.commit(function(err, txnResults) {
assert(!err);
db.legacyindex.readAsList(idx, 'thing', 'stuff', function(err, readResults) {
assert(!err);
assert.equal(readResults.length, 1);
assert.deepEqual(readResults[0], txnResults[person]);
done();
});
});
});
it('should support updating a rel', function(done) {

@@ -303,0 +254,0 @@ var txn = db.batch();

var db = require('./util/database').db();
var uniqn = require('./util/ponies').uniqn;
var _ = require('underscore');
var assert = require('assert');

@@ -139,12 +139,22 @@ var async = require('async');

var label = uniqn(), label1 = uniqn(), label2 = uniqn();
var txn = db.batch();
var neil = txn.save({name:'Neil'});
var jon = txn.save({name:'Jon'});
txn.label([neil, jon], label1);
txn.label(neil, label);
txn.label(jon, label2);
var all = txn.readLabels([neil, jon]);
txn.commit(function(err, result) {
async.auto({
nodes: function(cb) {
async.parallel({
neil: db.save.bind(db, {name:'Neil'}),
jon: db.save.bind(db, {name:'Jon'})
}, cb);
},
labels: ['nodes', function(cb, d) {
async.parallel([
db.label.bind(db, [d.nodes.neil, d.nodes.jon], label1),
db.label.bind(db, d.nodes.neil, label),
db.label.bind(db, d.nodes.jon, label2)
], cb);
}],
all: ['labels', function(cb, d) {
db.readLabels([d.nodes.neil, d.nodes.jon], cb);
}]
}, function(err, result) {
assert(!err);
var labels = result[all];
var labels = result.all;
assert(labels.length == 3);

@@ -164,2 +174,3 @@ assert(~labels.indexOf(label));

assert(result.length > 6);
assert.equal(_.uniq(result).length, result.length);
done();

@@ -166,0 +177,0 @@ });

@@ -11,3 +11,3 @@ var db = require('./util/database').db();

if (err)
assert.equal(err.statusCode, 404);
assert(err);
done();

@@ -89,12 +89,2 @@ });

it('should throw an error if attempting to save nodes with a label in batch mode', function(done) {
var label = uniqn();
var txn = db.batch();
txn.save({name:'Jon'}, label);
txn.commit(function(err, res) {
assert(err);
done();
});
});
it('should handle alternative id property name', function(done) {

@@ -310,3 +300,3 @@ function create(done) {

thingamajiggy, function(err, thingamajoggle) {
assert.ok(thingamajoggle[0] === null);
assert.ok(thingamajoggle[0] == null);
done();

@@ -401,4 +391,4 @@ });

assert.ok(!err);
db.read(user, function(err) {
assert.ok(!!err);
db.read(user, function(err, node) {
assert.ok(err || !node);
done();

@@ -450,3 +440,3 @@ });

}, function(err, res) {
assert.ok(!err, err);
assert.ok(!err, err && err.message);
done();

@@ -469,3 +459,2 @@ });

db.read(res.d, function(err, node) {
assert(err.statusCode == 404);
assert(!node);

@@ -499,4 +488,4 @@ done();

assert.ok(!err);
db.read([user1.id, user2.id], function(err) {
assert.ok(!!err);
db.read([user1.id, user2.id], function(err, node) {
assert.ok(!!err || (!node[0] && !node[1]));
done();

@@ -503,0 +492,0 @@ });

@@ -250,35 +250,2 @@ var db = require('./util/database').db();

it('should perform a cypher query w/o parsing the result', function(done) {
function createObjs(done) {
db.save([{name: 'Jon', age: 23},
{name: 'Neil', age: 60},
{name: 'Katie', age: 29}], function(err, users) {
done(null, users[0], users.slice(1));
});
}
function linkObjs(user1, users, done) {
db.relate(user1, 'knows', users, function(err, links) {
done(null, user1);
});
}
function queryRaw(user, done) {
var cypher = "start x = node(" + user.id + ") ";
cypher += "match (x) -[r]-> (n) ";
cypher += "return type(r), n.name, n.age ";
cypher += "order by n.name";
db.queryRaw(cypher, function(err, result) {
assert.ok(!err);
assert.deepEqual({
data: [['knows', 'Katie', 29], ['knows', 'Neil', 60]],
columns: ['type(r)', 'n.name', 'n.age']
}, result);
done();
});
}
async.waterfall([createObjs, linkObjs, queryRaw], done);
});
it('should handle optional entities', function(done) {

@@ -285,0 +252,0 @@ function createObjs(done) {

@@ -108,3 +108,3 @@ var db = require('./util/database').db();

db.rel.read(link.id, function(err, link) {
assert.ok(!!err);
assert.ok(!!err || !link);
assert.ok(!link);

@@ -111,0 +111,0 @@ })

@@ -5,4 +5,7 @@ /* Handles environment variables, all optional:

var nodeify = require('bluebird-nodeify');
var TEST_INSTANCE_PORT = parseInt(process.env.TEST_INSTANCE_PORT || '10507', 10);
var disposableSeraph = require('disposable-seraph');
var seraph = require('../../lib/seraph');

@@ -20,13 +23,7 @@ var _nsv;

if (err) return done(err);
var db = module.exports.db();
db.options.pass = 'neo4j';
var db = seraph({server:module.exports.url});
db.options.user = 'neo4j';
db.options.pass = 'test';
db.changePassword('test', function(err) {
if (err) {
if (err.code == 401)
done();
else
done(err);
return;
}
done()
done();
});

@@ -44,7 +41,17 @@ });

db: function() {
return require('../../')({
server: module.exports.url,
user: 'neo4j',
pass: 'test'
});
if (process.env.TEST_MODE == 'bolt') {
return seraph({
user: 'neo4j',
pass: 'test',
nodeify: true,
bolt: true
});
} else {
return seraph({
user: 'neo4j',
pass: 'test',
server: module.exports.url
});
}
return db;
},

@@ -51,0 +58,0 @@ refreshDb: refreshDb,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc