How to perform a many-to-many filter using ReferenceProperty in Google App Engine?

折月煮酒 提交于 2019-12-08 19:38:29

One common advice in the GAE community is to denormalize your models. This can be useful in this specific situation. You can store the club name in every player entity as a string, in addition to the reference property to the club:

 class Player(db.Model): 
     name = db.StringProperty()  
     link = db.LinkProperty()
     club = db.ReferenceProperty(club)
     club_name = db.StringProperty()

This would allow you to easily filter Players by club name.

Obviously, this makes changing club names harder. But the probability of having to change a club name is low.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!