开发者

how to create one-to-many relevance on google-app-engine

开发者 https://www.devze.com 2023-01-07 23:41 出处:网络
like one forum has开发者_开发技巧 many topic , ths specific is : forumand topic has the same model :

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


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).


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.

0

精彩评论

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