I have the following data model in Google Cloud Datastore:
Parent:
- name
Child:
- ancestor: Parent
- name
I have a list of Parent
keys. How can I query for all Child
entities descending from the list of Parent
keys ?
I have tried
SELECT * FROM Child WHERE __key__ HAS ANCESTOR Key(Parent, 'abc'), Key(Parent, 'dfe')
and
SELECT * FROM Child WHERE __key__ HAS ANCESTOR [Key(Parent, 'abc'), Key(Parent, 'dfe')]
and neither select statements work.
Cloud Datastore queries can operate on at most one ancestor, so you'd have to run this as two queries:
and merge the results.
Or if you can get away with fetching all
Child
entities, you could run: