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

seraph

Package Overview
Dependencies
Maintainers
1
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.3.0 to 0.3.1

8

lib/node.js

@@ -188,6 +188,10 @@ /* -*- Mode: Javascript; js-indent-level: 2 -*- */

*/
find: function(predicate, any, callback) {
find: function(predicate, any, start, callback) {
if (typeof any === 'function') {
callback = any;
any = false;
start = 'node(*)';
} else if (typeof start === 'function') {
callback = start;
start = 'node(*)';
}

@@ -209,3 +213,3 @@

var cypher = [
"START n = node(*) WHERE",
"START n = " + start + " WHERE",
matchers.join(any ? "or" : "and"),

@@ -212,0 +216,0 @@ "RETURN n"

@@ -8,3 +8,3 @@ {

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

@@ -11,0 +11,0 @@ "url": "https://github.com/brikteknologier/seraph"

@@ -286,3 +286,3 @@ # Seraph.js

<a name="node.find" />
### find(predicate, any, callback)
### find(predicate, [any, [start,]] callback)
*Aliases: __node.find__*

@@ -299,2 +299,4 @@

attribute. If false, elements must match on all attributes.
* start (optional, default=`'node(*)'`) - The scope of the search. For alternate
values, check the [neo4j docs on the cypher START command](http://docs.neo4j.org/chunked/stable/query-start.html).
* callback - function(err, results) - `results` is an array of the resulting

@@ -301,0 +303,0 @@ nodes.

@@ -855,2 +855,78 @@ /* -*- Mode: Javascript; js-indent-level: 2 -*- */

})
it('should find some items based on an OR predicate', function(done) {
var uniqueKey = 'seraph_find_test' + counter();
function createObjs(done) {
var objs = [ {name: 'Jon', age: 23},
{name: 'Neil', age: 60},
{name: 'Katie', age: 29} ];
for (var index in objs) {
objs[index][uniqueKey] = true;
}
objs[3] = {name: uniqueKey+'Belinda', age: 26};
objs[3][uniqueKey] = false;
db.save(objs, function(err, users) {
done();
});
}
function findObjs(done) {
var predicate = {};
predicate[uniqueKey] = true;
predicate['name'] = uniqueKey+'Belinda';
db.find(predicate, true, function(err, objs) {
assert.ok(!err);
assert.equal(objs.length, 4);
var names = objs.map(function(o) { return o.name });
assert.ok(names.indexOf('Jon') >= 0);
assert.ok(names.indexOf('Neil') >= 0);
assert.ok(names.indexOf('Katie') >= 0);
assert.ok(names.indexOf(uniqueKey+'Belinda') >= 0);
done();
});
}
async.series([createObjs, findObjs], done);
})
it('should find some items based on a predicate with a custom starting point', function(done) {
var uniqueKey = 'seraph_find_test' + counter();
function createObjs(done) {
var objs = [ {name: 'Jon', age: 23},
{name: 'Neil', age: 60},
{name: 'Katie', age: 29} ];
for (var index in objs) {
objs[index][uniqueKey] = true;
}
objs[3] = {name: 'Belinda', age: 26};
objs[3][uniqueKey] = false;
db.save(objs, function(err, users) {
users = users.slice(1);
db.index(uniqueKey, users, 'some_thing', 'perhaps', function() {
done();
})
});
}
function findObjs(done) {
var predicate = {};
predicate[uniqueKey] = true;
var startPoint = 'node:' + uniqueKey + '(some_thing="perhaps")';
db.find(predicate, false, startPoint, function(err, objs) {
assert.ok(!err);
assert.equal(objs.length, 2);
var names = objs.map(function(o) { return o.name });
assert.ok(names.indexOf('Jon') === -1);
assert.ok(names.indexOf('Neil') >= 0);
assert.ok(names.indexOf('Katie') >= 0);
assert.ok(names.indexOf('Belinda') === -1);
done();
});
}
async.series([createObjs, findObjs], done);
})
});

@@ -857,0 +933,0 @@

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