如何在 Google App Engine 的数据存储模型中获取行数?

如何在 Google App Engine 的数据存储模型中获取行数?

问题描述:

我需要在 App Engine 上获取特定模型的记录计数.怎么做?

I need to get a count of records for a particular model on App Engine. How does one do it?

我批量上传了 4000 多条记录,但 modelname.count() 只显示了 1000 条.

I bulk uploaded more than 4000 records but modelname.count() only shows me 1000.

您应该使用 数据存储统计:

Query query = new Query("__Stat_Kind__");
query.addFilter("kind_name", FilterOperator.EQUAL, kind);       
Entity entityStat = datastore.prepare(query).asSingleEntity();
Long totalEntities = (Long) entityStat.getProperty("count");

请注意,上述内容不适用于开发数据存储区,但可用于生产(发布时).

Please note that the above does not work on the development Datastore but it works in production (when published).

我看到这是一篇旧帖子,但我添加了一个答案,以帮助其他人搜索相同的内容.

I see that this is an old post, but I'm adding an answer in benefit of others searching for the same thing.