简体   繁体   English

在Google Cloud Datastore的开发人员控制台中按“键”过滤的正确语法是什么?

[英]What is the correct syntax to filter by 'Key' in the Developer Console for Google Cloud Datastore?

This is an old question on this topic, now it has new problem. 是关于这个主题的老问题,现在又有了新问题。

Update: Google update its console and this problem is solved. 更新:Google更新了其控制台,此问题已解决。 The right format is "Key('$YOUR_KIND'," + " " + $YOUR_VALUE + ")" . 正确的格式为"Key('$YOUR_KIND'," + " " + $YOUR_VALUE + ")" Please note that there must be only one space after comma, if your key is number then just write it, for example: Key('my_kind', 1234567890) , String type key need be quoted, for example: Key('MyKind', 'test_01') . 请注意,逗号后只能有一个空格,如果您的键是数字, Key('my_kind', 1234567890)写它,例如: Key('my_kind', 1234567890) ,字符串类型的键需要加引号,例如: Key('MyKind', 'test_01')

Original question. 原始问题。 Key('MyKind', 1) does not work, it shows Your request included invalid parameters without any meaningful information, I have to catch the network response and get the detail error description __key__ filter namespace is but query namespace is test01 . Key('MyKind', 1)不起作用,它显示Your request included invalid parameters没有任何有意义的信息,我必须捕获网络响应并获取详细的错误描述__key__ filter namespace is but query namespace is test01 Notice that there are two spaces between "... namespace is" and "but query ...", seems that I should add namespace in the key. 请注意,“ ...名称空间为”和“但是查询...”之间有两个空格,看来我应该在键中添加名称空间。 Does anyone know how to add it or some other way to solve this problem? 有谁知道如何添加它或其他方法来解决此问题?

Thank you very much. 非常感谢你。

SELECT * FROM Kind where __key__ = KEY('Kind', <id or name>)

So your example of Key('MyKind', 1) should have KEY as uppercase. 因此,您的Key('MyKind',1)示例应将KEY大写。 If you're using ids, then 1 is ok, if you're using names (ie strings) you must quote it. 如果您使用的是ID,那么1就可以了,如果您使用的是名称(即字符串),则必须将其引号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM