api
api copied to clipboard
Add unique flag to field block
Some fields such as article title are often required to be unique. Introducing a unique flag should check on matching document field values before accepting/rejecting based on results.
{
"type": "String",
"unique": true
}
Alternatively this could be handled in a hook. I will open a ticket for the changes required to achieve this.
Jeez, I was thinking about this yesterday! It could be part of the validation block, perhaps.
Yes I prefer the idea of being part of validation.
An alternative would be to hand this off to the storage engine by using a
unique index. Or perhaps by adding validation: { unique: true } a unique index is created automatically.
I like the DB-level concept. Is such a concept supported by all the current Edge DB modules?
Maybe the unique index would be better. Again, if 100% coverage with DBs.
MInd that an index adds load on write operations, you don't necessarily want an index on a field that must be unique. To me this seems more a validation requirement than a DB one.
Would that increased load be more or less than a pre-save match query on every unique field?
I'm happy with either but perhaps we should test both?