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?
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.
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.
Neosematix (n10s) through SHACL, can also create constrains on property types. It is not a simple as CREATE CONSTRAINT ...., but it works.