I'm quite new to node, neo4j, express, etc. so, I'm probably making some simple error.
I've been using your template as a guide for my app. I can write to the neo4j and create new nodes using cypher queries, but everything comes back as undefined.
example code:
User.getCourse = function(callback) {
var query = ['MATCH (class:Course:CMPT)',
'RETURN class'].join('\n');
db.query(query, function(err, results) {
if (err)
return callback(err);
var course = results.map(function (result) {
return result['class'];
});
callback(err, course);
});
};
result['class'] comes back undefined. The nodes exist in neo4j and I can do the same query in their browser to get results. Any ideas?
Yep: Cypher returns "results", so the returned results variable is always an array. You'll get what you want via results[0]['class']. This should fix your problem; feel free to reopen if it doesn't!
Hi Aseemk,
I'm quite new to node, neo4j, express, etc. so, I'm probably making some simple error.
I've been using your template as a guide for my app. I can write to the neo4j and create new nodes using cypher queries, but everything comes back as undefined.
example code: User.getCourse = function(callback) { var query = ['MATCH (class:Course:CMPT)', 'RETURN class'].join('\n');
};
result['class'] comes back undefined. The nodes exist in neo4j and I can do the same query in their browser to get results. Any ideas?