I am trying to ensure name uniqueness in a MongoAlchemy-backed model, and am uncertain how to go about it.
My first attempt involved writing a wrap validator which checked for existing database entries with the same name
and checked against them (to ensure that there were either 0 or 1 entries with the same name), but this failed because the validator only receives the string with the name
, not the entire object (so comparing mongo_id
s was impossible).
What's the best way to ensure that objects of a single class all have unique name
s?