Created
January 19, 2014 15:44
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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