Count
Cypher® COUNT subqueries can be created with new Cypher.Count().
To do this, a valid query needs to be passed to Count.
Note that count subqueries can also be used as predicates in WHERE clauses.
For example:
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 *
Simple Count subqueries
Instead of a Clause, a Pattern can be passed directly to a Count subquery:
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 *