Count
Cypher® COUNT 子查询 可以使用 new Cypher.Count() 创建。为此,需要将有效的查询传递给 Count。
请注意,计数子查询也可以在 WHERE 子句中用作谓词。例如
const subquery = new Cypher.Match(new Cypher.Node({ labels: ["Movie"] })).return("*");
const countExpr = new Cypher.Count(subquery);
const match = new Cypher.Match(new Cypher.Node())
.where(Cypher.gt(countExpr, new Cypher.Literal(10)))
.return("*");
MATCH (this0)
WHERE COUNT {
MATCH (this1:Movie)
RETURN *
} > 10
RETURN *
简单的 Count 子查询
可以直接将 Pattern 而不是 Clause 传递给 Count 子查询
const countExpr = new Cypher.Count(new Cypher.Pattern(new Cypher.Node(), { labels: ["Movie"] }))
const match = new Cypher.Match(new Cypher.Node())
.where(Cypher.gt(countExpr, new Cypher.Literal(10)))
.return("*");
MATCH (this0)
WHERE COUNT {
(this1:Movie)
} > 10
RETURN *