Google Cloud Datastore - What is the correct synta

2019-06-16 17:28发布

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)

enter image description here

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!

2条回答
够拽才男人
2楼-- · 2019-06-16 17:51

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).

查看更多
Melony?
3楼-- · 2019-06-16 17:54

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')
查看更多
登录 后发表回答