如何获取App引擎数据存储中的所有实体? [英] How to fetch all entities in App engine datastore?

查看:115
本文介绍了如何获取App引擎数据存储中的所有实体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://code.google.com/appengine中/docs/python/datastore/entities.html#Saving_Getting_and_Deleting_Entities



获取实体的批处理操作如下所示:



批量获取。实体= db.get([k1,k2,k3])



如何在不提供键的情况下获取所有实体?

解决方案

我得到了一个解决方案,可以在
Datastore Queries - Query interface example

= new Query(Person)
PreparedQuery pq = datastore.prepare(q);
for(实体结果:pq.asIterable()){
String firstName =(String)result.getProperty(firstName);
String lastName =(String)result.getProperty(lastName);
Long height =(Long)result.getProperty(height);
System.out.println(lastName ++ firstName +,+ height.toString()+inches tall);
}

我没有在查询中添加过滤器,因为它从数据存储返回所有实体。

in http://code.google.com/appengine/docs/python/datastore/entities.html#Saving_Getting_and_Deleting_Entities

the batch operation for getting the entity are stated below:

A batch get. entities = db.get([k1, k2, k3])

How can I fetch all entities without supplying keys?

解决方案

I got a solution on this and can be found in Datastore Queries - Query interface example:

Query q = new Query("Person") 
        PreparedQuery pq = datastore.prepare(q);  
    for (Entity result : pq.asIterable()) {   
       String firstName = (String) result.getProperty("firstName");   
       String lastName = (String) result.getProperty("lastName");   
       Long height = (Long) result.getProperty("height");   
       System.out.println(lastName + " " + firstName + ", " + height.toString() + "inches tall"); 
}

I did not add filter in query since it return all entities from datastore.

这篇关于如何获取App引擎数据存储中的所有实体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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