开发者

Unique Constraint At Data Level in GAE

It seems that the unique constraint is not natively supported in GAE, although one can enforce unique check before putting an object to store.

But that was in January 2009, what about now? Can I specify unique constraint on a column during schema creation? i.e.

class开发者_JAVA技巧 Account(db.Model):
  name = db.StringProperty()
  email = db.StringProperty() as unique # something like this
  @classmethod
  def create(cls, name, email):
    a = Account(name=name, email=email)
    a.put()
    return a


No, you still cannot specify unique during schema creation.

This issue is located here in case you want to watch it. It doesn't show up on their list of features on deck yet, so it seems like there are other features they will be working on first.


You can achieve a "unique constraint" in app engine's data store as described here. The example is presented in Java, but you should be able to apply the same concepts in python.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜