lowcoupling
lowcoupling

Reputation: 2169

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

 Entity.get_by_id(int(self.request.get('entityId')),parent=entityParent.key)

The ancestor version is apparently not supported

How should I handle it?

Upvotes: 0

Views: 173

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 600059

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)

Upvotes: 1

Related Questions