(self, filter=None, **kwargs)
return self._count(cmd, collation)
Get the number of documents in this collection.

        All optional count parameters should be passed as keyword arguments
        to this method. Valid options include:

          - `hint` (string or list of tuples): The index to use. Specify either
            the index name as a string or the index specification as a list of
            tuples (e.g. [('a', pymongo.ASCENDING), ('b', pymongo.ASCENDING)]).
          - `limit` (int): The maximum number of documents to count.
          - `skip` (int): The number of matching documents to skip before
            returning results.
          - `maxTimeMS` (int): The maximum amount of time to allow the count
            command to run, in milliseconds.
          - `collation` (optional): An instance of
            :class:`~pymongo.collation.Collation`. This option is only supported
            on MongoDB 3.4 and above.

        The :meth:`count` method obeys the :attr:`read_preference` of
        this :class:`Collection`.

        :Parameters:
          - `filter` (optional): A query document that selects which documents
            to count in the collection.
          - `**kwargs` (optional): See list of options above.

        .. versionchanged:: 3.4
           Support the `collation` option.
Get the number of documents in this collection.
Get the number of documents in this collection .
def count(self, filter=None, **kwargs):
        """Get the number of documents in this collection.

        All optional count parameters should be passed as keyword arguments
        to this method. Valid options include:

          - `hint` (string or list of tuples): The index to use. Specify either
            the index name as a string or the index specification as a list of
            tuples (e.g. [('a', pymongo.ASCENDING), ('b', pymongo.ASCENDING)]).
          - `limit` (int): The maximum number of documents to count.
          - `skip` (int): The number of matching documents to skip before
            returning results.
          - `maxTimeMS` (int): The maximum amount of time to allow the count
            command to run, in milliseconds.
          - `collation` (optional): An instance of
            :class:`~pymongo.collation.Collation`. This option is only supported
            on MongoDB 3.4 and above.

        The :meth:`count` method obeys the :attr:`read_preference` of
        this :class:`Collection`.

        :Parameters:
          - `filter` (optional): A query document that selects which documents
            to count in the collection.
          - `**kwargs` (optional): See list of options above.

        .. versionchanged:: 3.4
           Support the `collation` option.

        """
        cmd = SON([("count", self.__name)])
        if filter is not None:
            if "query" in kwargs:
                raise ConfigurationError("can't pass both filter and query")
            kwargs["query"] = filter
        if "hint" in kwargs and not isinstance(kwargs["hint"], string_type):
            kwargs["hint"] = helpers._index_document(kwargs["hint"])
        collation = validate_collation_or_none(kwargs.pop('collation', None))
        cmd.update(kwargs)
        return self._count(cmd, collation)
def count ( self , filter = None , * * kwargs ) : cmd = SON ( [ ( "count" , self . __name ) ] ) if filter is not None : if "query" in kwargs : raise ConfigurationError ( "can't pass both filter and query" ) kwargs [ "query" ] = filter if "hint" in kwargs and not isinstance ( kwargs [ "hint" ] , string_type ) : kwargs [ "hint" ] = helpers . _index_document ( kwargs [ "hint" ] ) collation = validate_collation_or_none ( kwargs . pop ( 'collation' , None ) ) cmd . update ( kwargs ) return self . _count ( cmd , collation )