Collect

Cypher® COLLECT 子查询表达式(不要与 collect() 函数混淆)可以通过 new Cypher.Collect() 创建。为此,需要将有效查询传递给 Collect,例如

const dog = new Cypher.Node({ labels: ["Dog"] });
const person = new Cypher.Node({ labels: ["Person"] });

const subquery = new Cypher.Match(
    new Cypher.Pattern(person).related(new Cypher.Relationship({ type: "HAS_DOG" })).to(dog)
).return(dog.property("name"));

const collectExpression = new Cypher.Collect(subquery)

const match = new Cypher.Match(person)
    .where(Cypher.in(new Cypher.Literal("Ozzy"), collectExpression))
    .return(person);
MATCH (this0:Person)
WHERE "Ozzy" IN COLLECT {
    MATCH (this0:Person)-[this1:HAS_DOG]->(this2:Dog)
    RETURN this2.name
}
RETURN this0
© . This site is unofficial and not affiliated with Neo4j, Inc.