Build configuration
Once a query is ready, the method build will generate the Cypher® and parameters required to run the query.
const { cypher, params } = query.build();
The method build accepts an object with options to configure the build process:
| Setting | Type | Default | Description |
|---|---|---|---|
|
String |
|
Define the default operator to use when using multiple labels in a Pattern. It can be either |
|
String |
|
If set, will prepend all queries with a |
|
String |
|
If set, will add a prefix to all variable names. See Customize Cypher® |
|
Object |
|
Add the provided parameters to the resulting params object. See Parameters |
|
Object |
|
Set of options to disable escaping from generated Cypher®. See Unsafe escape options |
Unsafe escape options
|
These options are dangerous, and changing them could lead to code injection. |
By default, Cypher® Builder will escape literal values, labels and relationship types when needed.
const movieNode = new Cypher.Node();
const matchQuery = new Cypher.Match(
new Cypher.Pattern(movieNode, {
labels: ["A Movie"]
})
);
const { cypher, params } = matchQuery.build();
MATCH (this0:`A Movie`)
The build options inside unsafeEscapeOptions change this behaviour:
| Setting | Type | Default | Description |
|---|---|---|---|
|
Boolean |
|
If set to true, labels will no longer be escaped |
|
Boolean |
|
If set to true, relationship types will no longer be escaped |
Example: Disable escaping for node labels and relationship types
const movieNode = new Cypher.Node();
const matchQuery = new Cypher.Match(
new Cypher.Pattern(movieNode, {
labels: ["A Movie"]
}).related({type: "ACTED IN"}).to()
);
const { cypher, params } = matchQuery.build({
unsafeEscapeOptions: {
disableNodeLabelEscaping: true,
disableRelationshipTypeEscaping: true,
}
});
Note that the following Cypher® is invalid
MATCH (this0:A Movie)-[:ACTED IN]->()