问题
I'm trying to query for an entity User in a Google cloud datastore with a key, using Googles developers console query filter. (Google Cloud Developer Console -> Cloud Datastore -> Query)

I fail to decipher the example syntax and am always prompted with the following error message:
Error: Keys for datastore operations must be in the format Key('kind0', 'name0'/id0, 'kind1', 'name1'/id1, ...)
On appengine.google.com I used to query for a specific key on a User like this:
SELECT * FROM User WHERE __key__ = Key('User','XXXXX')
I tried Key('User','XXXXX')
in the Google developers console but was always pointed to the error message above. Any ideas what the correct syntax would be?
Thanks in advance!
回答1:
The parser seems to be overly strict. As a workaround, you can add a space between the arguments to Key():
SELECT * FROM User WHERE __key__ = Key('User', 'XXXXX')
回答2:
What's the type of the key? Using Key('User', ) should work on the console. I tried here and it worked for an Entity named person with a numeric id. I used Key('Person',1).
来源:https://stackoverflow.com/questions/24417374/google-cloud-datastore-what-is-the-correct-syntax-to-filter-by-key-in-the-deve