Skip to content

Instantly share code, notes, and snippets.

@jexp
Created January 19, 2014 15:44
Show Gist options
  • Save jexp/8506572 to your computer and use it in GitHub Desktop.
Save jexp/8506572 to your computer and use it in GitHub Desktop.
Javascript Snippet to simply access transactional Cypher Http endpoint of the Neo4j Server (see http://docs.neo4j.org/chunked/milestone/rest-api-transactional.html)
var r=require("request")
function cypher(query,params,cb) {
r.post({uri:"http://localhost:7474/db/data/transaction/commit",
json:{statements:[{statement:query,parameters:params}]}},
function(err,res) { cb(err,res.body)})
}
var query="MATCH (n:User) RETURN n, labels(n) as l LIMIT {limit}"
var params={limit: 10}
var cb=function(err,data) { console.log(JSON.stringify(data)) }
cypher(query,params,cb)
{"results":[
{"columns":["n","l"],
"data":[
{"row":[{"name":"Aran"},["User"]]}
]
}],
"errors":[]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment