简体   繁体   English

在Cypher,Neo4j中处理空值

[英]Handling null values in Cypher, Neo4j

Is there any way in cypher where one can detect if the relationship been created is new? 密码中有什么方法可以检测到是否创建了新关系?

I am using merge to create a relationship if it doesn't exist. 我正在使用merge创建关系(如果不存在)。 If the relationship created is new then I want to set the value of that relationship to be 0 (relationship.value), or else if the relationship already exists while querying, then I want to increment its existing value. 如果创建的关系是新关系,那么我想将该关系的值设置为0(relationship.value),否则,如果查询时关系已经存在,则我想增加其现有值。

Please help 请帮忙

MERGE allows the optional usage of ON CREATE and ON MATCH : MERGE允许ON CREATEON MATCH的可选用法:

MATCH (a:Label {prop:'value1'}), (b:Label {prop:'value2'})
MERGE (a)-[r:relType]->(b)
ON CREATE SET r.myValue = 0
ON MATCH SET r.myValue = r.myValue + 1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM