Method: Mongo::Collection#count_documents
- Defined in:
- lib/mongo/collection.rb
#count_documents(filter = {}, options = {}) ⇒ Integer
Gets the number of documents matching the query. Unlike the deprecated #count method, this will return the exact number of documents matching the filter (or exact number of documents in the collection, if no filter is provided) rather than an estimate.
Use #estimated_document_count to retrieve an estimate of the number of documents in the collection using the collection metadata.
719 720 721 |
# File 'lib/mongo/collection.rb', line 719 def count_documents(filter = {}, = {}) View.new(self, filter, ).count_documents() end |