删除节点后,我有一个问题是在结果中获取节点记录。
我的查询是:
MATCH (user:User)-[:CREATED]->(comment:Comment)-[:BELONGS_TO]->(post:Post)
WHERE comment.uuid = {commentUUID} AND post.uuid = {postUUID} AND user.uuid = {userUUID} AND NOT EXISTS(user.deleted)
DETACH DELETE comment
RETURN comment
这里我删除属于某个帖子的评论(BELONGS_TO)。我还检查想要删除评论的用户是否也是此评论的作者(已创建)。
查询有效,删除节点和关系成功,但我对返回值不满意。
它显示了我的结果:
{ metadata: { deleted: true, id: 89 },
paged_traverse: 'http://myDatabaseURI/db/data/node/89/paged/traverse/{returnType}{?pageSize,leaseTime}',
outgoing_relationships: 'http://myDatabaseURI/db/data/node/89/relationships/out',
outgoing_typed_relationships: 'http://myDatabaseURI/db/data/node/89/relationships/out/{-list|&|types}',
labels: 'http://myDatabaseURI/db/data/node/89/labels',
create_relationship: 'http://myDatabaseURI/db/data/node/89/relationships',
traverse: 'http://myDatabaseURI/db/data/node/89/traverse/{returnType}',
all_relationships: 'http://myDatabaseURI/db/data/node/89/relationships/all',
all_typed_relationships: 'http://myDatabaseURI/db/data/node/89/relationships/all/{-list|&|types}',
property: 'http://myDatabaseURI/db/data/node/89/properties/{key}',
self: 'http://myDatabaseURI/db/data/node/89',
incoming_relationships: 'http://myDatabaseURI/db/data/node/89/relationships/in',
properties: 'http://myDatabaseURI/db/data/node/89/properties',
incoming_typed_relationships: 'http://myDatabaseURI/db/data/node/89/relationships/in/{-list|&|types}' }
感谢您的帮助!
编辑:
我将db URI隐藏在结果中,并将其替换为myDatabaseURI
答案 0 :(得分:1)
据我所知,当您删除节点时,您无法通过返回节点本身来返回其属性。
但是,您可以在删除之前获取节点的属性,并在删除节点本身后返回该节点:
MATCH (user:User)-[:CREATED]->(comment:Comment)-[:BELONGS_TO]->(post:Post)
WHERE comment.uuid = {commentUUID} AND post.uuid = {postUUID} AND user.uuid = {userUUID} AND NOT EXISTS(user.deleted)
WITH comment, properties(comment) as props
DETACH DELETE comment
RETURN props
但是,如果你需要返回它,你可以使用map projection来获取所有属性和节点id。