You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/ROOT/pages/directives/autogeneration.adoc
-2Lines changed: 0 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,8 +15,6 @@ This enables autogeneration of IDs for the field.
15
15
The format of each generated ID is a UUID generated by the link:https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-randomuuid[`randomUUID()` function].
16
16
The field will not be present in input types for mutations.
17
17
18
-
It is recommended to use xref::/directives/indexes-and-constraints.adoc#_unique[`@unique`] in conjunction with this to add a unique node property constraint.
The `@node` directive is used to change the database label mapping in this next example, so a unique constraint is asserted for the first label in the list, `Color`, and the property `hexadecimal`:
211
-
212
-
[source, graphql, indent=0]
213
-
----
214
-
type Colour @node(labels: ["Color"]) {
215
-
hexadecimal: String! @unique
216
-
}
217
-
----
218
-
219
-
In the following example, all labels specified in the `labels` argument of the `@node` directive are also checked when asserting constraints.
220
-
If there is a unique constraint specified for the `hexadecimal` property of nodes with the `Hue` label, but not the `Color` label, no error is thrown and no new constraints are created when running `assertIndexesAndConstraints`.
221
-
222
-
[source, graphql, indent=0]
223
-
----
224
-
type Colour @node(labels: ["Color", "Hue"]) {
225
-
hexadecimal: String! @unique
226
-
}
227
-
----
228
-
229
-
== Asserting constraints
230
-
231
-
In order to ensure that the specified constraints exist in the database, you need to run the function `assertIndexesAndConstraints`.
232
-
A simple example to check for the existence of the necessary constraints might look like the following, assuming a valid driver instance in the variable `driver`.
233
-
This checks for the unique node property constraint for the field decorated `@unique`, and checks for the index specified in `@fulltext`:
0 commit comments