thingdom / node-neo4j

[RETIRED] Neo4j graph database driver (REST API client) for Node.js
Apache License 2.0
925 stars 135 forks source link

Outdated docs for v2 #188

Closed mohuk closed 8 years ago

mohuk commented 8 years ago

I copied and pasted code from the README.md file and it failed with the message db.cypher is not a function

This did now work:

var neo4j = require('neo4j');
var db = new neo4j.GraphDatabase('http://username:password@localhost:7474');

db.cypher({
    query: 'MATCH (user:Person) RETURN user'
}, callback);

function callback(err, results) {
    if (err) throw err;
    var result = results[0];
    if (!result) {
        console.log('No user found.');
    } else {
        var user = result['user'];
        console.log(user);
    }
};

This worked:

    var neo4j = require('neo4j');
    var db = new neo4j.GraphDatabase('http://username:password@localhost:7474');

    db.query('MATCH (user:Person) RETURN user', callback);

    function callback(err, results) {
      if (err) throw err;
      var result = results[0];
      if (!result) {
        console.log('No user found.');
      } else {
        var user = result['user'];
        console.log(user);
      }
    };

I can submit a PR if this is only a docs update

aseemk commented 8 years ago

Hey @mohuk, sorry for the confusion: the docs say to just npm install neo4j, but you actually need to do npm install neo4j@2.0.0-RC2 on some versions of npm, it seems.

I hope to merge the v2 branch soon, at which point this will no longer be an issue.

I hope this helps, and sorry again!

mohuk commented 8 years ago

@aseemk I did figure that out after an hour of exercise :smile:. Looking forward to v2 but I am already pulling the RC2 in my current web app.