4

I have a list of keys for entites I want to read.
I can't find a way to read them in a single transaction

Is there a way to do something like this -

var query = datastore.createQuery('Task').filter('someProp', 'in', ['val1', 'val2'])

If someone knows about a specific solution for filtering according to multiple keys it will also work for me.
Thanks

Gyro
  • 944
  • 1
  • 8
  • 16

1 Answers1

2

The Cloud Datastore doesn't support OR operator and you need to perform separate queries per each value and combine and distinct the results on your end.

There is the Search API whole allows you to build documents and have more complex query for them but it is not avaliable for nodejs.

Related

Community
  • 1
  • 1
Shay Erlichmen
  • 31,691
  • 7
  • 68
  • 87
  • This only works for array type properties. It will return entities where the array someProp contains a value that equals val1 or val2. I trying to find entities where a property equals one of an array of possible values, but the property itself is a single field, like id. – Gyro Oct 22 '16 at 23:11
  • @Gyro you are right (it been a long time since I dealt with the Datastore), see new answer – Shay Erlichmen Oct 23 '16 at 11:52
  • You can only query for entities inside the same entity group (ancestor query) inside a transaction. – Dan Cornilescu Oct 23 '16 at 17:48