简体   繁体   English

如何从Google数据存储区获取最新实体?

[英]How to fetch newest entities from Google Datastore?

I am trying to query entities from Google Datastore and would like to fetch the 10 newest entities based on their time created property, but I am unsure about the functionality of the addSort method. 我正在尝试从Google Datastore查询实体,并希望根据其创建的时间属性获取10个 最新的实体 ,但是我不确定addSort方法的功能。

Will the addSort method fetch the newest 10 entities if I sort on the timeCreated property and limit the results to 10, or will this just fetch the entities using the default order and sort those results? 如果我对timeCreated属性进行排序并将结果限制为10,则addSort 方法将获取最新的10个实体,还是仅使用默认顺序来获取实体并对这些结果进行排序?

Here is the Query using the addSort method: 这是使用addSort方法的查询:

   Query q1 = new Query("Person").addSort("timeCreated", SortDirection.DESCENDING);

排序顺序会影响为查询扫描的索引,因此查询(有限制)将返回最近的实体。

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

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