Google App Engine Datastore: How to get entity by ID/Name if parent key is unknown?

Kappa Leonis picture Kappa Leonis · Jan 13, 2013 · Viewed 9.4k times · Source

There are two kinds of entity: User and Trip. User is parent to Trip and Trip is child to User.

For privacy consideration I am POSTing only Trip ID/Name. Because it is looks like a Trip Key contains encoded User ID/Name.

How to get entity by ID/Name if parent key is unknown?

Answer

Peter Knego picture Peter Knego · Jan 13, 2013

You can't. Parent key is part of the entity key and you need a full key to get an entity.

Also query with key filter won't find entities with parents unless you specify the ancestor key.