SelfReferenceProperty问题 [英] SelfReferenceProperty question

查看:110
本文介绍了SelfReferenceProperty问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆