如何在 google-app-engine 上创建一对多相关性

发布于 2024-09-10 11:42:26 字数 644 浏览 1 评论 0原文

就像一个论坛有很多主题,

具体是:论坛和主题具有相同的模型:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

海未深 2024-09-17 11:42:26

如果您想要多对多关系,@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).

静赏你的温柔 2024-09-17 11:42:26

这实际上是一个多对多的关系。一个论坛可以有多个主题。一个主题可以与多个论坛相关联。

请查看 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文