kiddouk / redisco

A Python Library for Simple Models and Containers Persisted in Redis

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Modelset count method

t20 opened this issue · comments

Is is possible (and useful) to implement a count feature in the modelset?

E.g.

from redisco import models
class Foo(models.Model):
... name = models.Attribute()
...
Foo(name="toto").save()
True
Foo(name="toto").save()
True
Foo.objects.count()
2

I forked this repo and I am interested in building this feature.

I think that his can easily be done with:

len(Foo.objects.all())

since the __len__ magic method is implemented in the Model class.