GithubHelp home page GithubHelp logo

aseemk / node-neo4j-template Goto Github PK

View Code? Open in Web Editor NEW
216.0 216.0 92.0 327 KB

A template app for using Neo4j from Node.js.

Home Page: http://node-neo4j-template.herokuapp.com/

JavaScript 88.26% CSS 0.56% HTML 11.19%

node-neo4j-template's People

Contributors

aseemk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-neo4j-template's Issues

`cypher` is not a function

Hi there!

I'm following your template, however I seem to have hit a snag (two, actually, and I assume they are related):

  1. I get a 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

  1. 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)

On users page, db error should propagate

/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?

data modelling

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?

Upgrade Cypher queries for Neo4j 2.0

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.

queries return undefined

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?

need a hint: how to query multiple nodes?

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

has no method 'follow'

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?

Returning data-only JSON

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?

_node issue - Error creating relationships

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

create unique node

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

Update Express / Most middleware (like favicon) is no longer bundled with Express

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.

Add Travis CI

  • Add .travis.yml
  • Update Heroku CD to wait for CI to pass now

Open questions and notes:

  • Test across multiple versions of Neo4j? Or just 2.2?
  • Travis's Neo4j is still on 1.9 (travis-ci/travis-ci#1803), so will have to manually install again.

getFollowingandOthers query problem - fix

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.