I'm fairly new to programming so forgive me if I ask an overly simplistic question, but I have no idea how to read the API documentation.
I was trying to put together a little server app that finds the shortest path between two nodes. I POST the data to the function "shortestpath" and it eventually filters through to a jade view. However, the string that is finally passed onto jade looks like [object Object]. When I JSON.stringify it, it ends up looking like:
var neo4j = require('neo4j');
var db = new neo4j.GraphDatabase('http://localhost:7474');
function resultants(neoPath, res){
res.render("results",{path: neoPath});
console.log("logging the path: ");
console.log(neoPath);
res.end('end');
}
function talkToNeo (nodeone, nodetwo, res) {
var params = {
};
var query = [
'MATCH (a {xml_id:"'+ nodeone +'"}),(b {xml_id:"' + nodetwo + '"}),',
'p = shortestPath((a)-[*..15]-(b))',
'RETURN (p)'
].join('\n');
console.log(query);
db.query(query, params, function (err, results) {
if (err) throw err;
var neoPath = results.map(function (result){
return result['p'];
});
console.log("this is the value of neoPath");
console.log(neoPath);
resultants(neoPath, res);
});
};
exports.shortestpath= function (req, res) {
console.log("exports at shortestpath called");
if (req.method == 'POST'){
console.log("if statement worked");
var nodeone = req.body.nodeone;
var nodetwo = req.body.nodetwo;
console.log(nodeone);
talkToNeo(nodeone, nodetwo, res);
};
};