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 1
1
.. uses tutorial.rst
2
2
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:
7
30
8
31
.. code-block:: python
9
32
10
33
>> posts.count_documents({})
11
34
3
12
35
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:
14
41
15
42
.. code-block:: python
16
43
You can’t perform that action at this time.
0 commit comments