0

I am new in GQL and facing problem while fetching records from cloud data store. I want to show records according to time when it is saving in data store and whose status is less than 2(i.e 0 or 1). Users whose details are saved recently comes on top in listing and then others. While saving details I am storing their timestamp also. Here is my query to retrieve the details whose status is 0 (which is working fine) but I want to retrieve details whose status is both 0 or 1.

"NOTE: Status datatype is string in datastore."

According to the GQL rule we can't use OR operator in it. So, what will be the solution for it. Anyone knows?


SELECT * FROM Users WHERE __key__ HAS ANCESTOR KEY(UsersDetails, 9623495224) AND status = '0' ORDER BY sent_on desc
Sukhpal Singh
  • 525
  • 1
  • 9
  • 29
  • Are all those `Users` entities you're querying for descendants of the `UsersDetails` entity with key ID `9623495224`? You should mention the structure of the ancestry tree you use. – Dan Cornilescu Jun 22 '18 at 01:16

1 Answers1

0

Instead of using OR you can do the following workaround:

SELECT * FROM Users WHERE __key__ HAS ANCESTOR KEY(UsersDetails, 9623495224) AND status >= 0 AND status <= 1 ORDER BY sent_on desc

Note that for this case you should convert the data to int. You can check the reference here