别名

WITHRETURN 语句中,通常使用变量进行别名。为此,需要传递一个包含值及其别名的元组。

别名为字符串

当别名为字符串时,你应该这样操作

const node = new Cypher.Node({
    labels: ["Movie"],
});
const withQuery = new Cypher.With([node, "my-alias"]);
WITH this0 AS my-alias

别名为变量

你可以将别名设为 Cypher®.Variable,而不是精确的字符串,这样它可以像其他变量一样重复使用。

const movieNode = new Cypher.Node({ labels: ["Movie"] });
const myVar = new Cypher.Variable();
const match = new Cypher.Match(movieNode).with([movieNode, myVar]).return([myVar, "Film"]);
MATCH (this0:`Movie`)
WITH this0 AS var1
RETURN var1 AS Film

在前面的示例中,MATCH 之后,节点变量 this0WITH 语句中被别名为任意名称的变量(var1)。最后,在 RETURN 中,该变量被别名为将要返回的特定名称 Film

© . This site is unofficial and not affiliated with Neo4j, Inc.