Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature neo4j adapter #138

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Making find work
craigedmunds committed Mar 26, 2015
commit 3f4a67e34df258cb27b32d69f5ee64620db3c10a
18 changes: 15 additions & 3 deletions lib/adapters/neo4j.js
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ adapter._init = function (options) {
// mongoose.set('debug', options.debug);

//Setup mongoose instance
this.db = new neo4j.GraphDatabase('http://localhost:7474');
this.db = new neo4j.GraphDatabase('http://172.17.0.2:7474');

console.log("Init DB", this.db);
};
@@ -180,19 +180,31 @@ adapter.find = function(model, query, projection){
adapter.findMany = function(model, query, projection) {
console.log("neo4j findMany", query, projection); //model, );
var that = this;

if (query.id) {
//Don't know why this is coming into findMany with id - would expect it to go into .find...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's complicated process of parsing a query and we shrunk .find to single line that adds additional {limit: 1} and passes query to .findMany. Also - there's no point feeding database with complex query if it has single id. This might happen in fortune hooks that modify clients query, e.g. security one.


return new Promise(function (resolve, reject) {

that.db.getNodeById(query.id, function(err, node) {
// resolve([node]);
console.log("getNodeById callback", err, node);
console.log("getNodeById callback", err.length, node);
resolve([{ id : query.id }])
});

});
}
else {
return new Promise(function (resolve, reject) {

that.db.getIndexedNodes(null, null, null, function(err, node) {
// resolve([node]);
console.log("getIndexedNodes callback", err.message, node);
resolve([{ id : query.id }])
});

});

}

// return [{ id : query.id }];