我正在尝试连接sigma.js和neo4j。对于连接,我想使用此代码:
sigma.neo4j.cypher_parse = function(result) {
var graph = { nodes: [], edges: [] },
nodesMap = {},
edgesMap = {},
key; ...
但我不知道变量结果究竟是什么意思。
答案 0 :(得分:2)
You trying the internal function of cypher plugin, it's cool.
Take a look at the JSdoc of the method :
/**
* This function parse a neo4j cypher query result, and transform it into
* a sigma graph object.
*
* @param {object} result The server response of a cypher query.
*
* @return A graph object
*/
So result is the result of the neo4j server. You can take a look at neo4j transaction endpoint : http://neo4j.com/docs/stable/rest-api-transactional.html#rest-api-begin-and-commit-a-transaction-in-one-request
So result is a json object like this one :
{
"results" : [ {
"columns" : [ "id(n)" ],
"data" : [ {
"row" : [ 15 ]
} ]
} ],
"errors" : [ ]
}
But why you don't want to use the plugin with its main function like this :
mySigmaInstance = new sigma({
graph: {
nodes: [],
edges: []
},
container: 'graph-container'
});
sigma.parsers.cypher(
{ url: 'http://localhost:7474', user:'neo4j', password:'admin' },
'MATCH (n) OPTIONAL MATCH (n)-[r]->(m) RETURN n,r,m LIMIT 100',
mySigmaInstance,
function() {
// Put here your custom code
// It's the callback function
mySigmaInstance.refresh();
}
);