-1
class Author(db.Model):
name = db.StringProperty()
class Story(db.Model):
author = db.ReferenceProperty(Author)
story = db.get(story_key)
author_name = story.author.name
author = db.get(author_key)
stories_by_author = author.story_set.get()
衆所周知,使用ReferenceProperty是數據關係的良好解決方案,如上所示。 所以;例如,我們在「作者」和「故事」實體(表格)中有大量的行。多年後,我們刪除了「作者」實體或將名稱替換爲另一個名稱。自然地;我們的應用sholud拋出錯誤。 這種情況(管理代碼)是否合理或者手動執行關係是否良好?這種情況下是否有其他模式?是否在Google App Engine數據存儲中使用ReferenceProperty-合理?