How to query to more than one ancestor on google cloud datastore?

2 views
Skip to first unread message

Dan McGrath via StackOverflow

unread,
May 9, 2017, 6:48:04 PM5/9/17
to gcd-stac...@googlegroups.com

You cannot - you'd need to issue a separate query for each ancestor.

Workarounds

Depending on what you are trying to achieve, there are several methods to work around this limitation.

Note, all these workarounds would lose the "strong consistency" promise that is provided by ancestor queries, whereby results between entities in A, B, and C entity groups will not be strongly consistent.

1. Kindless Queries

If you are actually trying to query for all objects regardless of ancestor, you could issue a kindless query - in GQL this is SELECT *

2. Index a new Property

If you know the set of ancestors you need to query for in advanced, you could index a Boolean property when you initially write the entity. For example, create a new property called is_abc that is set to True if it has any of them as an ancestor. You can then use this property to query for all entities under those 3 entities.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/40286401/how-to-query-to-more-than-one-ancestor-on-google-cloud-datastore/40291837#40291837
Reply all
Reply to author
Forward
0 new messages