aseemk / node-neo4j-template Goto Github PK
View Code? Open in Web Editor NEWA template app for using Neo4j from Node.js.
Home Page: http://node-neo4j-template.herokuapp.com/
A template app for using Neo4j from Node.js.
Home Page: http://node-neo4j-template.herokuapp.com/
Hi there!
I'm following your template, however I seem to have hit a snag (two, actually, and I assume they are related):
db.createConstraint
is not a function error. I commented it out, and was able to node app.js
.However, then, trying to access any data (specifically via REST) gives me
cypher is not a function
for db.cypher.You can see it re-created in the REPL here:
> db
GraphDatabase {
reviveJSON: [Function],
url: 'http://neo4j:neo4j@localhost:7474',
_request:
{ get: [Function],
post: [Function],
put: [Function],
del: [Function],
head: [Function] },
_root: null,
_services: null }
> db.cypher
undefined
> db.cypher()
TypeError: db.cypher is not a function
at repl:1:4
at REPLServer.defaultEval (repl.js:164:27)
at bound (domain.js:250:14)
at REPLServer.runBound [as eval] (domain.js:263:12)
at REPLServer.<anonymous> (repl.js:392:12)
at emitOne (events.js:82:20)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:210:10)
at REPLServer.Interface._line (readline.js:546:8)
at REPLServer.Interface._ttyWrite (readline.js:823:14)
/users
shows "no users currently" if it can't reach the database. That shouldn't be the case; it should propagate the error. Is this a bug in the node-neo4j lib? Or something we're doing wrong here?
hi fork,
I am developing social networking website. I am using mysql as primary database and jeo4j
(in-memory store) for maintainig relations between my website users. I am developing this
website in node.js
I have read this blog (https://github.com/aseemk/node-neo4j-template/blob/master/models/user.js)
and trying to do as mentioned in blog/document. But I am not getting, how do I do?
I have data modelling in mysql as follows :
table : UserMst ( UserID (PrimaryKey), UserName, FullName, EMail, MobileNo etc...)
table : Friends ( FriendID (PrimaryKey), UserID, FriendID )
Now, when some user come on website through login process, I have to check wather it is exist
in neo4j (I have UserID). If He/she doesn't exist in jeo4j then insert it with it basic
details (eg. UserID, UserName, FullName, EMail, MobileNo) or get it's stored information.
after that I am going to fetch his/her friend detail from mysql. Now I have to insert that
all friends in neo4j if they not exist and then join/link each other.
I have tried to do above senario as mentioned in diffrent blogs, but I have not getting success.
Can anyone sugess/guid me How do I do this?
But the Neo4j team's hosted instance (that the running Heroku app points to) is still version 1.8. I've reached out to ask when it'll be 2.0.
Instead of using native Neo4j IDs directly
E.g. a new username
property.
Hi Aseemk,
I'm quite new to node, neo4j, express, etc. so, I'm probably making some simple error.
I've been using your template as a guide for my app. I can write to the neo4j and create new nodes using cypher queries, but everything comes back as undefined.
example code:
User.getCourse = function(callback) {
var query = ['MATCH (class:Course:CMPT)',
'RETURN class'].join('\n');
db.query(query, function(err, results) {
if (err)
return callback(err);
var course = results.map(function (result) {
return result['class'];
});
callback(err, course);
});
};
result['class'] comes back undefined. The nodes exist in neo4j and I can do the same query in their browser to get results. Any ideas?
Hi Aseem,
is there a simple way to return (and query the properties of) multiple nodes? Template works great for single nodes, looking for a method to handle multiple nodes from a cypher query. I can create callback variables for each node...seems like there should be a better way
User.get = function (username, callback) {
var query = [
'MATCH (user:User {username: {username}})-[:WATCHED]->(movie:MOVIE)',
'RETURN user, movie',
].join('\n')
var params = {
username: username,
};
db.cypher({
query: query,
params: params,
}, function (err, results) {
if (err) return callback(err);
if (!results.length) {
err = new Error('No such user with username: ' + username);
return callback(err);
}
var user = new User(results[0]['user']);
var movie = new User(results[0]['movie']);
callback(null, user, movie);
});
};
Thanks! Michael
Like Peter and I did here: https://github.com/neo4j-examples/node-neo4j-template
That would be awesome!
It'd be cool to show an example of a non-trivial Cypher query to derive something cool. I'm thinking a "normalized" follower count could be cool, where followers are given more weight if they follow fewer other people.
Prototyped: https://gist.github.com/aseemk/8049714
when I am going to connect node with each other, It gives me following error :
TypeError: Object [object Object] has no method 'follow'
can someone help me?
I'm trying to create a server of this general format that returns JSON (for use by a client) instead of rendering HTML. However, it returns the JSON with all the metadata from both node-neo4j and Neo4j itself. All I want is the data. This is relatively easy to filter at the top level (ex. routes/users.js) except for functions returning multiple results like User.getAll. I tried modifying the lower level models/users.js, but then it became evident that the User prototype wrapper is useful for combined queries like a User.get followed by user.getFollowingAndOthers. I can think of some ways to rearchitect this for this use case, but any thoughts on how to do it in a sane way?
Hi, I have set up a simple app to test out creating nodes and relationships in Neo4j.
https://github.com/rorymadden/neo4j-test
I am able to create nodes ok but I am having difficulties creating a relationship.
The relationship is failing with an error message of Error: Failed to create relationship
I have based my code on the node-neo4j-template and tried to see what difference there is with my code. This is where I am getting very confused. The relevant code is below:
User.prototype.follow = function (other, callback) {
console.log('other node: '+other._node);
this._node.createRelationshipTo(other._node, 'follows', {}, function (err, rel) {
callback(err);
});
};
I have added in a console.log to inspect the structure of the other node. If I JSON.stringify and print out other._node I get identical syntax to my code. However when I print other._node on its own I get a difference. In my code I get [object Object] but with the node-neo4j-template code I get 'node @15'. I believe that this is what is causing the relationship to fail.
The main difference between the two apps is that I have more than one node type (server model). I have users and projects. The only thing I can think of is that I am creating a new DB instance in each model which may cause the difference. However can you please elaborate on how _other.node prints out as node @15? THis may help me to resolve the problem.
Thanks for your help
How do we create unique node? and I also want unique index on some of my node property. (eg. If my node is a type of user, then it should be unique username, email and mobileno.)
thanks
I have a database neo4j empty and when i click in View all users, put in terminal error:
TypeError: Object # has no method 'split'.
What can i need to do?
Hi,
I know that's an all project but you're still featured by Neo4J, so here I am ๐
When typing npm start
after installing every packages and neo4j, this error occurs:
Most middleware (like favicon) is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.
at Function.Object.defineProperty.get (/Users/tnguyen/tutorials/Neo4JTemplate/node_modules/express/lib/express.js:99:13)
at Object.<anonymous> (/Users/tnguyen/tutorials/Neo4JTemplate/app.js:17:16)
at Module._compile (module.js:434:26)
at Module._extensions..js (module.js:452:10)
at Object.nodeDevHook [as .js] (/Users/tnguyen/tutorials/Neo4JTemplate/node_modules/node-dev/lib/hook.js:43:7)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/tnguyen/tutorials/Neo4JTemplate/node_modules/node-dev/lib/wrap.js:58:1)
I guess a little update is just required.
.travis.yml
Open questions and notes:
I loaded this project based on your recomendations on twitter and got it to work half way. There is a problem with your Cypher Query data retrieval for the following part.
Currently it is - var follows = results[i][count(rel)];
It should be - var follows = results[i][COUNT(rel)];
as it is returning none of the followers to the caller function.
After these changes all worked as expected.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.