Google App Engine ndb equivalent for modelname_set (backreference property)

前端 未结 1 1616
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-16 01:42

Is there an equivalent for modelname_set (a back-referenced property) in Google App Engine\'s NDB?

In the old DB a Model entity had described the back-r

相关标签:
1条回答
  • 2020-12-16 02:25

    There is no direct back-reference properties in NDB because NDB doesn't quite use the same paradigm as the original datastore client. You would use a KeyProperty for your forward reference and then use a query for everything that has that KeyProperty set for your back reference.

    class Comment(ndb.Model)
        source = ndb.KeyProperty()
    
    qry = Comment.query().filter(source=ndb.Key('Source', 'Sandy'))
    
    0 讨论(0)
提交回复
热议问题