键只使用一个键进行查询 [英] Keys only query, using a key
本文介绍了键只使用一个键进行查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用一个键做一个简单的只有键的查询(所以要测试它在数据存储中的存在)。
I want to do a simple Key-Only query using a key (so to test the existence of it in the datastore).
在java中这样做最简单的方法是什么?
Whats the simplest way in java of doing this?
推荐答案
为了通过键检查一个实体的存在,最简单和最便宜的方法是简单地使用 get()
:
For checking the existence of one entity by key, the simplest and cheapest would be to simply use get()
:
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
datastore.get(KeyFactory.createKey(kind, long) )
Get(1 read操作)查询更便宜(1阅读+ 1小): http://code.google .com / appengine / docs / billing.html
Get (1 read operation) is cheaper the query (1 read + 1 small): http://code.google.com/appengine/docs/billing.html
这篇关于键只使用一个键进行查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文