1
votes

I'm looking to query for Datastore Entities by parent key (i.e., to return entities with keys that are 1 path segment under the parent key). I know that I can use a HAS_ANCESTOR query to get the parent and all descendants, but I only want the immediate children.

I was hoping a __parent__ property would be available for this purpose, but this does not seem to work:

{propertyFilter: {
  property: {name: '__parent__'},
  op: 'EQUAL',
  value: {keyValue: {
    partitionId: {projectId: 'myproject'},
    path: [{kind: 'row', name: 'parent'}]
  }}
}

I know I can also record a depth property in each entity to achieve this, but would rather not do that if Datastore supports a query like this natively using the key itself.

1

1 Answers

1
votes

No, this is not currently supported. If the kind of the child is unique to the particular depth in question you can just use that, otherwise you need to create a composite index that includes indexing of a 'depth' property as you mentioned.