Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-02-2021 01:01 PM
I have been reading cypher documentation but am still very unsure on how to achieve the following:
Set a constraint on n:LABEL nodes in such way that n.property1 must be a positive integer
Set a constraint on n:LABEL nodes in such wayt that n.property2 must contain one of the values specified in an "enum" (or whatever would be the neo4j equivalent)
The idea here is that I would like to enforce a specific type of schema through constraints. Are either of these in any way possible with just plain cypher?
Solved! Go to Solution.
03-02-2021 01:15 PM
Hello,
Neither of these constraint types are currently supported, though we do have an interest in expanding our constraint types in the future.
Currently on node properties we support uniqueness, existence, and node key constraints.
You could implement a before-commit trigger (via APOC or with your own transaction listener) to check for such conditions and fail the transaction if it doesn't adhere to what you're expecting.
03-02-2021 01:15 PM
Hello,
Neither of these constraint types are currently supported, though we do have an interest in expanding our constraint types in the future.
Currently on node properties we support uniqueness, existence, and node key constraints.
You could implement a before-commit trigger (via APOC or with your own transaction listener) to check for such conditions and fail the transaction if it doesn't adhere to what you're expecting.
03-02-2021 01:28 PM
Thank you! I had not considered APOC functions as a way to trigger transaction fail in case of invalid values - I will start digging through APOC documentation next.
05-16-2021 08:19 PM
Neosematix (n10s) through SHACL, can also create constrains on property types. It is not a simple as CREATE CONSTRAINT ...., but it works.
All the sessions of the conference are now available online