Using Key in NDB to retrieve an entity

前端 未结 1 1336
长情又很酷
长情又很酷 2021-01-24 22:24

I have this structure: Books that have Chapters (ancestor=Book) that have Pages (ancestor=Chapter)

It is clear for me that, to search for a Chapter by ID, I need the boo

相关标签:
1条回答
  • 2021-01-24 22:54

    You can do this in one go by doing an ancestor query, rather than a get:

    chapter_key = ndb.Key('Book', long(bookId), 'Chapter', long(chapterId))
    page = Page.query(Page.pageNumber==pageNumber, ancestor=chapter_key)
    
    0 讨论(0)
提交回复
热议问题