code: def count(cls, filter=None, **kwargs):
          
          from mongoframes.queries import Condition, Group, to_refs
  
          if isinstance(filter, (Condition, Group)):
              filter = filter.to_dict()
  
          return cls.get_collection().count(to_refs(filter), **kwargs)
docs: Return a count of documents matching the filter