如何在 google-app-engine 上创建一对多相关性
就像一个论坛有很多主题,
具体是:论坛和主题具有相同的模型:
class Geo(db.Model):
#self = db.SelfReferenceProperty()
title = db.StringProperty()
link = db.StringProperty()
updated = db.DateTimeProperty(auto_now =True)
author = db.ReferenceProperty(MyUser)
id = db.StringProperty()
entry_keys = db.ListProperty(db.Key)
summary = db.StringProperty(multiline=True)
point = db.StringProperty()
@property
def entry(self):
return [db.get(key) for key in self.entry_keys]
它们都是geo-rss格式,我在这个地方使用ListProperty,但是ListProperty有最大大小,
所以我必须找到其他方法,
所以什么我应该这样做,
谢谢
like one forum has many topic ,
ths specific is : forum and topic has the same model :
class Geo(db.Model):
#self = db.SelfReferenceProperty()
title = db.StringProperty()
link = db.StringProperty()
updated = db.DateTimeProperty(auto_now =True)
author = db.ReferenceProperty(MyUser)
id = db.StringProperty()
entry_keys = db.ListProperty(db.Key)
summary = db.StringProperty(multiline=True)
point = db.StringProperty()
@property
def entry(self):
return [db.get(key) for key in self.entry_keys]
all they are a geo-rss format , i use ListProperty this place ,but ListProperty has max size ,
so i have to find other method,
so what i should do ,
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想要多对多关系,@thethimble 的建议很好。不过,如果您确实想要多对一关系,则可以使用SelfReferenceProperty 从论坛到主题 - 与任何其他ReferenceProperty,它也会在引用的实体上创建一个隐式集合属性(只有一个,而引用者有很多)。
If you want a many-to-many relationship, @thethimble's suggestion is good. If you do want a many-to-one relationship, though, you could use a SelfReferenceProperty from forum to topic -- like any other ReferenceProperty, that, too, makes an implicit collection property on the referenced entity (the one, while the referencers are the many).
这实际上是一个多对多的关系。一个论坛可以有多个主题。一个主题可以与多个论坛相关联。
请查看 Google App Engine 文档中的多对多部分。
This is actually a many-to-many relationship. A forum can have multiple topics. One topic can be associated with multiple forums.
Check out the many-to-many section in the Google App Engine documentation.