【问题标题】:Retrive all the entities from a datastore [closed]从数据存储中检索所有实体 [关闭]
【发布时间】:2013-06-27 15:54:54
【问题描述】:

我正在使用 App Engine Datastore 中的低级 API。要检索我使用的实体

Entity post = datastore.get(postKey);

但此代码将仅返回带有此 postkey 的帖子。如果我想退回所有帖子该怎么办?

【问题讨论】:

标签: java google-app-engine google-cloud-datastore low-level-api


【解决方案1】:

您需要进行查询,而不是获取,

通过 id 获取一个实例, 查询是您查询的结果。

只是做:

// Use class Query to assemble a query
Query q = new Query("Post");

// Use PreparedQuery interface to retrieve results
PreparedQuery pq = datastore.prepare(q);


for (Entity result : pq.asIterable()) {
  String postName = (String) result.getProperty("PostName");
}

【讨论】:

  • 2019年已经不行了。
猜你喜欢
  • 2014-12-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-03-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多