seraph: get db.query array values

173 views Asked by At

This code gives me... array? with columns and data, as i understand

console.log

{ columns: [ 'n.name' ],
  data: [ [ '(' ], [ 'node_name' ], [ ';' ], [ 'CREATE' ], [ ')' ] ] }

Code

function show() {
    var cypher = [
     'MATCH (n)-[r:CREATE_NODE_COMMAND]->(s)RETURN n.name'
     ].join('\n');
        db.queryRaw(cypher, {}, function(err, result) {
  if (err) throw err;
for (var key in result) {
}       
      console.log(result);
        })}

How to get clean data: keys like this (n.name;CREATE) ?

2

There are 2 answers

0
Pavel Vanchugov On

result.data.join('') by jonpacker https://github.com/brikteknologier/seraph/issues/166

5
Dave Bennett On

If you want to return a map of key : value in the cypher result set you can change the return statement to something like this...

return { name : n.name }