密码:从已删除的关系中获取信息 [英] Cypher: Get info from deleted relationships
问题描述
MATCH (n:Topic { mongoId: {_id} })-[r]-() DELETE n,r RETURN r;
返回错误错误:关系1509已被删除".
That returns the error 'Error: Relationship 1509 has been deleted'.
但是,我需要r.mongoId
删除另一个数据库中的条目.
However, I need r.mongoId
to delete entries in another database.
如何使用Neo4j 2.2.3做到这一点?
How do I do this with Neo4j 2.2.3?
我正在通过 Seraph库进行此操作.有没有办法收集属性,删除关系并返回集合?
I'm doing this through the Seraph library. Is there a way to collect a property, delete the relationships, and return the collection?
我只需要以下数据:MATCH (n:Topic { mongoId: _id })-[r]-() RETURN COLLECT(r.mongoId);
谢谢!
推荐答案
在删除节点和关系之前,可以使用WITH
子句为要返回的数据添加别名.像这样:
You can use a WITH
clause to alias the data you want to return before deleting the node and relationship. Something like this:
MATCH (n:Topic {mongoId: {_id} })-[r]-()
WITH r.mongoId as docId, n,r
DELETE n,r
RETURN docId
或者您可以将其分为两个查询,一个查询检索所需的属性,第二个查询删除关系和节点.
Or you could break it up into two queries, one to retrieve the property you want, then the second to delete the relationship and node.
编辑:您很可能希望指定直接关系,以避免返回重复的docId
属性:
EDIT: you most likely want to specify a directed relationship to avoid duplicate docId
properties returned:
MATCH (n:Topic {mongoId: {_id} })-[r]->()
...
这篇关于密码:从已删除的关系中获取信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!