'Counter. Allows to execute for example
.. code-block:: python
db.count(db.all, \'id\')
And it will return then how much records are in your ``id`` index.
.. warning::
It sets ``kwargs[\'with_storage\'] = False`` and ``kwargs[\'with_doc\'] = False``'

def count(self, target_funct, *args, **kwargs):

    kwargs['with_storage'] = False
    kwargs['with_doc'] = False
    iter_ = target_funct(*args, **kwargs)
    i = 0
    while True:
        try:
            iter_.next()
            i += 1
        except StopIteration:
            break
    return i
