re-using an entity's ID for other entities of different kinds - sane idea?

后端 未结 1 1511
北恋
北恋 2020-11-27 08:16

My (python) app is using several entities, many of them in a 1:1 relationship. For example:

class Main(ndb.Model):
    field1 = ndb.StringProperty()
    #pee         


        
相关标签:
1条回答
  • 2020-11-27 09:03

    I use this approach all the time for many years, and never had any problems.

    For example, every time you update an entity, every indexed field is updated too. For this reason, I often split a complex entity into "rarely updated" part and "frequently updated" part, and use different kinds but the same ID for both entities, e.g. AdEntity and AdCounterEntity. This way, as you correctly observed, the app logic is simplified as you need to remember only one ID to retrieve both entities as necessary.

    0 讨论(0)
提交回复
热议问题