Open isaacguerreir opened 1 year ago
Hey Isaac,
I can see how this can be confusing given how I've worded it. What actually happens, is that Neogma will assume that it's unique, and will use it for deleting nodes etc. To make sure that they are actually unique, you need to enforce it, e.g. via a unique index.
Please let me know if it clear things up for you.
How could I enforce it in practice (e.g. codewise)?
Another question is: would be interesting to have an optional in the model to allow neogma return the ID created by Neo4J?
How could I enforce it in practice (e.g. codewise)?
You can create a unique constraint. So, in your case it would be
CREATE CONSTRAINT vendor_name_unique
FOR (vendor:Vendor) REQUIRE vendor.name IS UNIQUE
But I would recommend providing your own id to the Vendor nodes.
Another question is: would be interesting to have an optional in the model to allow neogma return the ID created by Neo4J?
Yeah this is a good idea!
I created a simple example where field name of a Model is set to be a primary key.
In the docs, it says it's a unique identifier.
I made a test and I created two Vendors with the same database. Why it is possible if both of them are unique identifiers? Is it a Neo4J thing?