ndb verify entity uniqueness in transaction
问题 I've been trying to create entities with a property which should be unique or None something similar to: class Thing(ndb.Model): something = ndb.StringProperty() unique_value = ndb.StringProperty() Since ndb has no way to specify that a property should be unique it is only natural that I do this manually like this: def validate_unique(the_thing): if the_thing.unique_value and Thing.query(Thing.unique_value == the_thing.unique_value).get(): raise NotUniqueException This works like a charm