zl程序教程

您现在的位置是:首页 >  其它

当前栏目

Neo4j parameter

Parameter Neo4j
2023-09-27 14:24:45 时间

 Neo4j browser:

$ :help param

Set a parameter

Set a parameter to be sent with queries.

The :param name => 'Stella' command will define a parameter named "name" and it will be sent along with your queries. 
Using parameters, rather than hard coding values, will allow for reuse of the query plan cache

The right hand side of => is sent to the server and evaluated as Cypher with an implicit RETURN in front. This gives better type safety since some types (especially numbers) in JavaScript are hard to match with Neo4j:s type system. 
To set a param as an integer, do :param x => 1 and to set it as a float, do :param x => 1.0.

Cypher query example with a param:  MATCH (n:Person) WHERE n.name = $name.

 

$ :help params

Parameters

View and set parameters to be sent with queries.

The :params command will show you a list of all your current parameters.

Note that setting parameters using this method does not provide type safety with numbers. 
Instead we advise you to set each param one by one using the :param x => 1 syntax. 
See :help param for more info.

The :params {name: 'Stella', age: 24} command will replace your current parameters with the new parameters defined in the object.


转载:

作者:wry2008wry 
来源:CSDN 
原文:https://blog.csdn.net/wry2008wry/article/details/82984473 
版权声明:本文为博主原创文章,转载请附上博文链接!

neo4j browser中定义参数变量

 

概念

在neo4j browser网页中调试cypher语句时,使用预先定义的变量会更方便且增加代码的可读性,类似于SQL语句中的参数。

参数对当前会话有效,网页刷新变量消失。变量为一个kv的键值对。

定义的语法是

:param a:1, b:2

:param {a: 1, b: 2}

如上,定义方式为一个冒号+param+空格+参数,注意有一个空格。有两种方式定义变量 :叠加的方式、整体的方式。

 

叠加方式

即将多个变量列出来,以追加的方式,如果变量的key已经存在则替换已有的,否则新建,如:

:param a:1, b:2

 

整体方式

整体更新定义变量的键值对,以前所有的变量被覆盖:

:param {a: 1, b: 2}

 

显示所有变量

在命令框中输入

:params

 

使用变量

先定义一个列表类型的变量

:param items:[1, 2,  3]

使用变量:

UNWIND $items as item

return item

注意使用变量的时候在变量名前中一个$,和phpe及shell类似
---------------------