philippkueng / node-neo4j

Neo4j REST API wrapper for Node.js
MIT License
211 stars 44 forks source link

Added option to get stats returned when running a cypher query. #31

Closed oskarhane closed 10 years ago

oskarhane commented 10 years ago

I recently had to run CREATE UNIQUE for relationships and the only way to find out if a relation was created is to get hold of te stats and look at stats.relationships_created like this:

db.cypherQuery(q, {}, function(err, res) {
    if(res.stats.relationships_created > 0) {
        //Relation created
    }
})

I wasn't sure where you wanted this setting to be set, but since it's not very common I figured that it's easiest just to add it as a parameter to the function call.

philippkueng commented 10 years ago

Thanks a lot @oskarhane for the PR. Truly valuable. I'll have one minor point and i will comment right into the code.

oskarhane commented 10 years ago

Good point @philippkueng. I pushed a new commit to fix the issues.