在节点上不工作的密码查询。但是从neo4j的控制台工作。

时间:2022-01-12 18:07:03

I am trying to write a node.js app that works with neo4j, using the node-neo4j module. I am trying to submit a query from nodejs and found it wasn't working, so I tried submitting it from the neo4j browser console, in order to more easily root cause my typo, and found that it worked properly there. Any ideas as to what is going on?

我在写一个节点。使用node-neo4j模块与neo4j一起工作的js应用程序。我正在尝试从nodejs中提交一个查询,发现它不工作,所以我尝试从neo4j浏览器控制台提交它,以便更容易地查找导致我输入错误的根源,并发现它在那里正常工作。有什么想法吗?

The query:

查询:

Match (a:Paper { uid:26327110, citation:"Seitz A.  \"Moving beyond a binary view of specificity in perceptual learning.\" Journal of vision. 15 12 (2015 Sep 1): 1422.", date:"2015 Sep 1"}) return a

2 个解决方案

#1


2  

You should probably be using parameters anyway and they might help with any encoding issues. That would look like this:

无论如何,您应该使用参数,它们可能有助于解决任何编码问题。看起来是这样的:

var query_string = "MATCH (a:Paper {attributes}) RETURN a"

var attributes = {uid: 26327110, citation: "Seitz A. \"Moving beyond a binary view of specificity in perceptual learning.\" Journal of vision. 15 12 (2015 Sep 1): 1422.", date: "2015 Sep 1"};

db.cypherQuery(query_string, {attributes: attributes});

Of course you can use individual parameters for individual values if you like. Not only do parameters help you not worry about encoding, but the allow Neo4j to cache the query. Also, if you are passing in values from the user parameters also help you to prevent injection attacks.

当然,如果您愿意,您可以使用单独的参数。参数不仅可以帮助您不必担心编码,而且允许Neo4j缓存查询。此外,如果您正在从用户参数中传递值,也可以帮助您防止注入攻击。

#2


2  

In this situation, it turns out I was just an idiot - the error occurred because I created a new database with a new password and forgot to adjust my node server's authentication. If you ever have a similar issue and see the following error in your node console: [Error: HTTP Error 401 when running the cypher query against neo4j. undefined: undefined] then you too, have a case of the idiot. As Kunal suggested in the comments to the original question, check your authentication.

在这种情况下,结果证明我只是个傻瓜——出现错误是因为我用新的密码创建了一个新的数据库,忘记调整节点服务器的身份验证。如果您曾经遇到过类似的问题,并在您的节点控制台中看到以下错误:[error:针对neo4j运行cypher查询时,HTTP error 401。那你也有个白痴的例子。正如库纳尔在对原始问题的评论中所建议的,检查您的身份验证。

#1


2  

You should probably be using parameters anyway and they might help with any encoding issues. That would look like this:

无论如何,您应该使用参数,它们可能有助于解决任何编码问题。看起来是这样的:

var query_string = "MATCH (a:Paper {attributes}) RETURN a"

var attributes = {uid: 26327110, citation: "Seitz A. \"Moving beyond a binary view of specificity in perceptual learning.\" Journal of vision. 15 12 (2015 Sep 1): 1422.", date: "2015 Sep 1"};

db.cypherQuery(query_string, {attributes: attributes});

Of course you can use individual parameters for individual values if you like. Not only do parameters help you not worry about encoding, but the allow Neo4j to cache the query. Also, if you are passing in values from the user parameters also help you to prevent injection attacks.

当然,如果您愿意,您可以使用单独的参数。参数不仅可以帮助您不必担心编码,而且允许Neo4j缓存查询。此外,如果您正在从用户参数中传递值,也可以帮助您防止注入攻击。

#2


2  

In this situation, it turns out I was just an idiot - the error occurred because I created a new database with a new password and forgot to adjust my node server's authentication. If you ever have a similar issue and see the following error in your node console: [Error: HTTP Error 401 when running the cypher query against neo4j. undefined: undefined] then you too, have a case of the idiot. As Kunal suggested in the comments to the original question, check your authentication.

在这种情况下,结果证明我只是个傻瓜——出现错误是因为我用新的密码创建了一个新的数据库,忘记调整节点服务器的身份验证。如果您曾经遇到过类似的问题,并在您的节点控制台中看到以下错误:[error:针对neo4j运行cypher查询时,HTTP error 401。那你也有个白痴的例子。正如库纳尔在对原始问题的评论中所建议的,检查您的身份验证。