thingdom / node-neo4j

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

Query on Graph not working #137

Closed Gabxi closed 10 years ago

Gabxi commented 10 years ago

So in my callback function, I did a console.log on the graph to make sure that it exists. However, when I run this code

var query = [
    'MATCH (n { id: {id} })-[r]->nbr', 
    'RETURN n,r,nbr',
    'LIMIT 100'
];
graph.query(query.join('\n'), {id:2}, function(err, results) {
    if (err) {
        console.log(err);
        console.log(err.stack);
    }
    else {
        for (var i = 0; i < results.length; i++) {
            var relationship = results[i].r;
            var node = results[i].m;
            console.log(node);
        }
    }
});

I get this error TypeError: Cannot read property 'hostname' of undefined at Request.send (./node_modules/neo4j-js/lib/Neo4jApi.js:195:27) at new Request (./node_modules/neo4j-js/lib/Neo4jApi.js:188:9) at Graph.query (./node_modules/neo4j-js/lib/Graph.js:84:55)

Any help would be appreciated. I apologize if this the wrong place to post this.

hackintoshrao commented 10 years ago

StackOverflow would be a better place to take this up .. The issue is not with your query , its with the Database connectivity . Please make sure the neo4j server is running and you have initialized your graph object via the following code var neo4j = require('neo4j'); var graph = new neo4j.GraphDatabase('http://localhost:7474');

aseemk commented 10 years ago

I agree, it sounds like you're not passing a URL to the GraphDatabase constructor, which you need to be doing. See for example this:

https://github.com/aseemk/node-neo4j-template/blob/master/models/user.js#L5-L9