Google Cloud Datastore - What is the correct syntax to filter by Key in the Developer Console?

徘徊边缘 提交于 2019-12-08 16:55:16

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!