且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 NDB 中使用 Key 来检索实体

更新时间:2023-02-13 12:18:00

您可以通过执行祖先查询而不是获取来一次性完成此操作:

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)