Alan Hamlett
Alan Hamlett

Reputation: 3274

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.

Upvotes: 2

Views: 83

Answers (1)

schickling
schickling

Reputation: 4240

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.

Upvotes: 2

Related Questions