SelfReferenceProperty问题 [英] SelfReferenceProperty question
问题描述
我正在尝试使用google appengine。我有这个模型:
$ $ p $ def Human(db.Model):
name = db.StringProperty()
friends = db.SelfReferenceProperty()
这个人有不止一个朋友。那么,如何用google appengine处理这个问题?
对于简单的多对多关系,使用 ListProperty
和一个键列表。
如果你需要存储额外的元数据,给模型自己的关系,例如友谊
。
这两个示例都可以在@ http://code.google.com/appengine/articles/modeling.html
I am trying to use google appengine. I have this model:
def Human(db.Model):
name = db.StringProperty()
friends = db.SelfReferenceProperty()
This Human has more than one friend. So, how to handle this with google appengine?
For simple many-to-many relationships, use a ListProperty
with a list of keys.
If you need to store additional metadata, give the model its own relationship, e.g. Friendship
.
Examples of both can be found @ http://code.google.com/appengine/articles/modeling.html
这篇关于SelfReferenceProperty问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!