lowcoupling lowcoupling - 1 month ago 5x
Python Question

Google Datastore: get_by_id with an ancestor

I am trying to retrieve an entity from a ndb Datastore
I know the id and an ancestor (not the parent!)

Although this query works fine when knowing the parent


The ancestor version is apparently not supported

How should I handle it?


You can't do a get for that, since that is only for exact keys and you don't have one. You need to do an ancestor query:

Entity.query(Query.id==int(self.request.get('entityId')), ancestor=ancestor.key)