如何在 Google App Engine 的数据存储模型中获取行数? [英] How does one get a count of rows in a Datastore model in 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.
这篇关于如何在 Google App Engine 的数据存储模型中获取行数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文