Search code examples
sqlgraphcool

Prevent duplicates for a certain GraphCool model


I have a GraphCool model called Student which has a field called studentNumber. How can I prevent two (or more) different Student nodes with the same studentNumber? In SQL databases I was able to create a unique index to accomplish this.


Solution

  • The easiest way to do so is by enabling the "Unique" constraint for a certain field (studentNumber in your case for the Student model). You can enable constraints in the structure view when editing a model.

    Note: Under the hood, this creates a unique index in the database just like you suggested.