lowcoupling lowcoupling - 1 year ago 152
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?

Answer Source

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)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download