Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.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

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 在Neo4j中检索节点列表以及与其直接相关的节点ID列表_Node.js_Neo4j_Cypher - Fatal编程技术网

Node.js 在Neo4j中检索节点列表以及与其直接相关的节点ID列表

Node.js 在Neo4j中检索节点列表以及与其直接相关的节点ID列表,node.js,neo4j,cypher,Node.js,Neo4j,Cypher,在我的数据库中,我有:User节点,它们通过:友谊关系关联。我想得到一个这样的结构: [ { id: 1, username: "Whatever", email: "whatever@test.com" ... }, [ 6, 7, 8, ... ] ], [ { id: 2, username: "Another user", email: "ano

在我的数据库中,我有:User节点,它们通过:友谊关系关联。我想得到一个这样的结构:

[
    {
        id: 1,
        username: "Whatever",
        email: "whatever@test.com"
        ...
    },
    [ 6, 7, 8, ... ]
],
[
    {
        id: 2,
        username: "Another user",
        email: "anotheruser@test.com"
        ...
    },
    [ 15, 16, 17, 18, ... ]
],
...
…其中,数字是该节点与:友谊关系直接相关的节点的ID

这个答案有一些问题几乎可以解决:

但最接近我的是:

match p=(a:User)-[:Friendship]->(d:User)
return d, reduce(nodes = [],n in nodes(p) | nodes + [id(n)]) as node_id_col
…返回此结构:

[
    {
        id: 1,
        username: "Whatever",
        email: "whatever@test.com"
        ...
    },
    [ 1, 6 ]
],
[
    {
        id: 1,
        username: "Whatever",
        email: "whatever@test.com"
        ...
    },
    [ 1, 7 ]
],
[
    {
        id: 1,
        username: "Whatever",
        email: "whatever@test.com"
        ...
    },
    [ 1, 8 ]
],
[
    {
        id: 2,
        username: "Another user",
        email: "anotheruser@test.com"
        ...
    },
    [ 2, 15 ]
],
[
    {
        id: 2,
        username: "Another user",
        email: "anotheruser@test.com"
        ...
    },
    [ 2, 16 ]
],
...
这并不好,因为它返回了大量冗余数据

那么,什么才是正确的密码查询呢


谢谢

我想你可能把事情复杂化了,或者我没有正确理解这个问题。像这样的东西对你有用吗

match (a:User)-[:Friendship]->(d:User)
return a, collect(id(d))