class_docstr: Wrap MongoDB with three primary methods `read`, `write`, `remove`.
  
  Attributes
  ----------
  host : str
     Hostname or MongoDB compliant full credentials+address+database
     specification.
  
  Information on MongoDB `connection string
  <https://docs.mongodb.com/manual/reference/connection-string/>`_.
  
  .. seealso:: :class:`orion.core.io.database.Database` for more on attributes.
docstr: Count the number of documents in a collection which match the `query`.
  
  .. seealso:: :meth:`orion.core.io.database.Database.count` for argument documentation.
docstr_tok: ["Count","the","number","of","documents","in","a","collection","which","match","the","`","query","`",".","..","seealso",":",":",":","meth",":","`","orion.core.io.database.Database.count","`","for","argument","documentation","."]
code: def count(self, collection_name, query=None):
      """Count the number of documents in a collection which match the `query`.
  
      .. seealso:: :meth:`orion.core.io.database.Database.count` for argument documentation.
  
      """
      dbcollection = self._db[collection_name]
      if not isinstance(
          getattr(dbcollection, "count_documents"),
          pymongo.collection.Collection,
      ):
          return dbcollection.count_documents(
              filter=query if query else {}
          )
  
      return dbcollection.count(filter=query)
  
imports: import functools
  import pymongo
  from orion.core.io.database import Database, DatabaseError, DatabaseTimeout, DuplicateKeyError
label_desc: Use image node_id 16 for calling the MongoDB obj's underlying member method code with example usage: obj.count(collection_name, query) and returns: dbcollection, dbcollection