How does one get a count of rows in a Datastore model in Google App Engine?

后端 未结 8 1827
日久生厌
日久生厌 2020-12-05 10:13

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

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

相关标签:
8条回答
  • 2020-12-05 10:45

    In GAE a count will always make you page through the results when you have more than 1000 objects. The easiest way to deal with this problem is to add a counter property to your model or to a different counters table and update it every time you create a new object.

    0 讨论(0)
  • 2020-12-05 10:54
    count = modelname.all(keys_only=True).count(some_upper_limit)
    

    Just to add on to the earlier post by dar, this 'some_upper_limit' has to be specified. If not, the default count will still be a maximum of 1000.

    0 讨论(0)
提交回复
热议问题