Skip to content Skip to sidebar Skip to footer

Working With Ancestors In Gae

I only want that someone confirm me that I'm doing things in the right way. I have this structure: Books that have Chapters (ancestor=Book) that have Pages (ancestor=Chapter) It is

Solution 1:

No, there's no need to do that. The point is that keys are paths: you can build them up dynamically and only hit the datastore when you have a complete one. In your case, it's something like this:

page_key = ndb.Key(Book, bookId, Chapter, chapterId, Page, pageId)
page = page_key.get()

See the NDB docs for more examples.

Post a Comment for "Working With Ancestors In Gae"