File tree Expand file tree Collapse file tree 1 file changed +32
-5
lines changed Expand file tree Collapse file tree 1 file changed +32
-5
lines changed Original file line number Diff line number Diff line change 11.. uses tutorial.rst
22
3- If we just want to know how many documents match a query we can
4- perform a the ``~pymongo.collection.Collection.count_documents`` method operation
5- instead of a full query. We can get a count of all of the documents
6- in a collection:
3+ .. _pymongo-count:
4+
5+ =====
6+ Count
7+ =====
8+
9+ .. contents:: On this page
10+ :local:
11+ :backlinks: none
12+ :depth: 1
13+ :class: singlecol
14+
15+ .. facet::
16+ :name: genre
17+ :values: reference
18+
19+ .. meta::
20+ :keywords: number, amount
21+
22+ To see how many documents are in a collection, use the
23+ ``~pymongo.collection.Collection.count_documents()`` method.
24+
25+ Count All Documents
26+ -------------------
27+
28+ To return a count of all documents in the collection, pass an empty object to
29+ the ``count_documents()`` method, as shown in the following example:
730
831.. code-block:: python
932
1033 >> posts.count_documents({})
1134 3
1235
13- or just of those documents that match a specific query:
36+ Count Specific Documents
37+ ------------------------
38+
39+ To return a count of documents that match specific search criteria, specify a
40+ query in the ``count_documents()`` method, as shown in the following example:
1441
1542.. code-block:: python
1643
You can’t perform that action at this time.
0 commit comments