Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 如何从cypher查询中使用nodejs获取对象?_Node.js_Neo4j_Cypher - Fatal编程技术网

Node.js 如何从cypher查询中使用nodejs获取对象?

Node.js 如何从cypher查询中使用nodejs获取对象?,node.js,neo4j,cypher,Node.js,Neo4j,Cypher,我有以下问题,这是我想要的-: 'START user=node({userId}), other=node({otherId})', 'MATCH (user) -[rels?]-> (other)', 'RETURN rels' 但我无法访问它发送的对象。我需要以下我不知道要访问的高亮度对象 在下面的控制台中检查对象-: [{"rels":{"db":{"url":"http://localhost:7474","_request":{},"_root":..

我有以下问题,这是我想要的-:

'START user=node({userId}), other=node({otherId})',
      'MATCH (user) -[rels?]-> (other)',
      'RETURN rels'
但我无法访问它发送的对象。我需要以下我不知道要访问的高亮度对象

在下面的控制台中检查对象-:

[{"rels":{"db":{"url":"http://localhost:7474","_request":{},"_root":..........{},"start":"http://localhost:7474/db/data/node/222","property":"http://localhost:7474/db/data/relationship/245/properties/{key}","self":"http://localhost:7474/db/data/relationship/245","properties":"http://localhost:7474/db/data/relationship/245/properties","type":"knows","end":"http://localhost:7474/db/data/node/196","data":{"created_at":1372829579654}},"_start":{"db":{"url":"http://localhost:7474","_request":{},"_root":...
完整程序:

User.checkRelationship = function (user, fid, callback) {

  var uids = [user.uid, fid];
  async.map(uids, User.by_uid, function (err, usernodes) {
    if (!err && usernodes && usernodes.length) {
    User.relsCheck(usernodes, function (err, rels) {
        if (!err && rels) {
          callback(null, rels);  // inpecting rels gave the above object but I want to return rels.type , but is not giving i want
        } else {
          callback(err || new Error('relationships does\'nt exists'));
        }
      });
    } else {
      callback(err || new Error('Unable to fetch user nodes: ' + uids.join(',')));
    }
  });
};


User.relsCheck = function (nodes, callback) {
  if (nodes.length !== 2) {
    return callback(new Error('Invalid/insufficient arguments'));
  }
  var query = [
      'START user=node({userId}), other=node({otherId})',
      'MATCH (user) -[rels?]-> (other)',
      'RETURN rels'
  ].join('\n');

  var params = {
    userId: nodes[0].node().id,
    otherId: nodes[1].node().id,
  };

   db.query(query, params, callback);
};

如果您想访问原始结果,可以只访问原始$.post并读取结果