1

Is there a way how to query all GAE Datastore entities that have a parent of a given kind? Each entity has a key that consists of a kind and id/name and we would like to query by that kind. Is this somehow possible to use that information in a query? Or do we have to store the kind in a separate property and then use that property in the query?

Nathan
  • 141
  • 9

1 Answers1

1

That's an interesting question. If you mean, given an Entity of kind A, where A's parent can be of kind B, C, ..., find all of the A's that have a parent of kind B, then I'm pretty sure that the answer is that this isn't doable in a single query, other than iterating across all As, examining their parent's kind. (If I discover otherwise, I'll revise this answer).

Given this problem, I'd store the parent kind as a separate (string) property.

Dave W. Smith
  • 24,318
  • 4
  • 40
  • 46
  • Yes, this is exactly what I mean. You can find the reason why I need such a functionality here [link](http://stackoverflow.com/questions/19094030/spring-security-acl-on-app-engine-datastore). However, there may be better model for my requirement. Any idea? – Nathan Oct 19 '13 at 08:25
  • You had the right thought. If you want to optimize this for queries, denormalize, and store the parent kind in a separate property. – Dave W. Smith Oct 19 '13 at 14:33