Define labels in pattern instead of relying on Node/Relationship variables
Instead of relying on withoutLabels and withoutProperty, labels used in a Pattern should be defined in the pattern, instead of the Cypher.Node and Cypher.Relationship types.
There are 2 alternatives for achieving this:
Option 1: Using a chained command pattern, similar to current solution
new Cypher.Pattern({ variable: movie, labels: ["Movie"] })
.related()
.withDirection("left")
.withLength("*")
.to({ labels: ["Actor"] })
.withProperties({
name: new Cypher.Param("Keanu"),
});
Option 1.5: Same as before but with labels in a method
new Cypher.Pattern(movie)
.withLabels("Movie")
.related()
.withDirection("left")
.withLength("*")
.to()
.withLabels(["Actor"])
.withProperties({
name: new Cypher.Param("Keanu"),
});
Option 2: Use objects chained with related and to
new Cypher.Pattern({
variable: movie,
labels: ["Movie"],
})
.related({
direction: "left",
length: "*",
})
.to({
labels: ["Actor"],
properties: {
name: new Cypher.Param("Keanu"),
},
});
Regardless of the option to be implemented, the Cypher.Node and Cypher.Relationship types should be maintained as sugar syntax, but every possible pattern should be possible to produce with plain variables.
The following methods should be deprecated:
withoutLabelswithoutVariablewithoutType- (optionally)
getVariables
Related Discussion: https://github.com/neo4j/cypher-builder/discussions/293
This also requires hasLabel and hasType methods to be available in variables