linkyndy/remodel

Implement count() for Model, RelatedSet and RelatedM2MSet

linkyndy opened this issue · 1 comments

Model, RelatedSet and RelatedM2MSet should implement a count() method to leverage counting documents for a particular model/set.

Currently, in order to see how many document a model counts, we need to:

len(list(Model.all()))

With count(), everything will become a lot simpler:

Model.count()

As with the latest changes (by introducing ObjectHandler), finding the number of documents a model counts has been reduced to:

len(Model.all())

It would be nice though to be able to use a helper method, count() to do this. It will come in handy especially for counting related documents in one-to-many and many-to-many relations.

A couple of more examples:

User.count()
recipe['ingredients'].count()