如何使用实体键在GQL中进行查询 [英] How do I query in GQL using the entity key

查看:91
本文介绍了如何使用实体键在GQL中进行查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在查看器中,第一列(Id / Name)显示为 name = _1 ,在详细视图中显示为

 解码实体密钥:程序:name = _1 
实体密钥:agtzcG9 ...................

此查询不起作用:

  SELECT * FROM Program name ='_1'


解决方案

您可以使用实体的密钥来检索它:

  SELECT * FROM Program where __key__ = KEY('agtzcG9 ......... ..........')

而且,您应该可以使用查询名称类似:

  SELECT * FROM程序其中__key__ = KEY(程序,'_1')

请注意,这不是您想在AppEngine应用程序中执行的操作N;正如尼克在评论中所指出的那样,这是对时间的巨大浪费。真的,这个例子只是向你展示如何在管理控制台中通过Key进行查询。


How do I write a query against the entity key using GQL in the Google App Engine Data Viewer ?

In the viewer, the first column (Id/Name) displays as name=_1, in the detail view it shows the key as

Decoded entity key: Programme: name=_1
Entity key: agtzcG9................... 

This query does not work:

SELECT * FROM Programme where name = '_1'

解决方案

You can use the entity's key to retrieve it:

SELECT * FROM Programme where __key__ = KEY('agtzcG9...................')

And, you should be able to query using the name similarly:

SELECT * FROM Programme where __key__ = KEY(Programme, '_1')

Note that this is not something that you would want to do in your AppEngine application; as Nick notes in his comment, it is a huge waste of time. Really, this example is only good to show you how to query by Key in the Admin console.

这篇关于如何使用实体键在GQL中进行查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆