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 可选匹配不返回结果_Node.js_Neo4j - Fatal编程技术网

Node.js 可选匹配不返回结果

Node.js 可选匹配不返回结果,node.js,neo4j,Node.js,Neo4j,当我在neo4j浏览器(localhost:7474/browser)中启动此查询时 …我明白了:(sg.title和s.title都有数据) 当我在nodejs中将相同的查询推入此函数时(使用npm请求模块): …我明白了:(只有s.title有数据) 我在neo4j node和seraph模块中尝试了相同的方法,它们都给出了相同的结果(sg.title=null) 然而,当我使用邮递员时,一切又恢复了正常 POST localhost:7474/db/data/cypher 将主体(原始)设

当我在neo4j浏览器(localhost:7474/browser)中启动此查询时

…我明白了:(sg.title和s.title都有数据)

当我在nodejs中将相同的查询推入此函数时(使用npm请求模块):

…我明白了:(只有s.title有数据)

我在neo4j node和seraph模块中尝试了相同的方法,它们都给出了相同的结果(sg.title=null)

然而,当我使用邮递员时,一切又恢复了正常

POST localhost:7474/db/data/cypher 将主体(原始)设置为


知道为什么这在浏览器和邮递员中有效,但在节点中无效吗?

您需要解析
recId
,使其成为整数,而不是字符串。(请注意,得出此结论所需的信息未包含在本页中,但在上


当您将其解析为字符串时,cypher尝试比较
id(sg)
“294”
的相等性,一个是整数,另一个是字符串。在JS中工作,但在cypher中不工作。

更清楚一点:我没有在params对象中使用parseInt()。var params={recId:parseInt(req.params.recId)};(节省了周末)
match (s:Song)
optional match (sg:SongGroup)-[r:SONGGROUP_SONG]->(s) where id(sg) = 294
return sg.title , s.title
sg.title    s.title
test 3      Shake it off
....        .....
function cypherQuery(query, params, callback) {
  request.post({
      uri    : 'http://localhost:7474/db/data/cypher',
      json   : {query: query, params: params}
    },
    function(err, res, body) {
      callback(err, body);
    });
{ columns: [ 's.title', 'sg.title' ],
  data: 
   [ [ 'My forbidden lover', null ],
     [ 'Step back', null ],
     [ 'Shake it off', null ],
     [ 'Two Hearts', null ],
     [ 'Homelands', null ] ] }
{
  "query" : "match (s:Song) optional match (sg:SongGroup)-[r:SONGGROUP_SONG]->(s) where id(sg) = {recId} return s.title, sg.title ",
  "params" : {"recId": 294}

}