首页 > 解决方案 > 如何在 AgnsGraph 中修改以下密码语法?

问题描述

MATCH (wu:wiki_user) 可选匹配 (n:wiki_doc{author:wu.uid}), (o:wiki_doc{editor:wu.uid}) RETURN wu.uid AS User_id, wu.org AS Organization, wu.email AS email, wu.token AS balance, count(n) AS Writing, count(o) AS Modifying;

  user_id | organization |      email      | balance | writing | modifying
 --------------------------------------------------------------------------
  "ailee" | "Org2"       | "hazel@gbc.com" | 5       |       0 |         0
  "hazel" | "Org1"       | "hazel@gbc.com" | 5       |       2 |         2


 match (n:wiki_doc{editor:'hazel'}) return n;

n

  wiki_doc[9.11]
{"bid": "hazel_doc1", "cid": "Basic", "org": "Org1", "title": "Hello world!", 
"author": "hazel", "editor": "hazel", "revnum": 1, "created": "2018-09-25 
09:00:000", "hasfile": 2, "contents": "I was wrong", "modified": "2018-09-25 
10:00:000"}

(1 行)

实际上,在hazel的情况下更新次数是1,使用上面的查询时使用了2次查询。

如何修改查询,使只能正常查看一个。

标签: cypher

解决方案


MATCH( wu:wiki_user)
OPTIONAL MATCH (n:wiki_doc{author:wu.uid}), (o:wiki_doc{editor:wu.uid}) RETURN wu.uid AS User_id, wu.org AS Organization, wu.email AS email, wu.token AS balance,
count(distinct id(n)) as Writing, count(distinct id(o))as Modifying;

  user_id | organization |        email        | balance | writing | modifying

 +----------------------------------------------------------+

 "ailee" | "Org2"       | "hazel@gbc.com"     | 5       |       0 |         0

 "hazel" | "Org1"       | "hazel@gbc.com"     | 5       |       2 |         1

(2 行)


推荐阅读