Skip to content

Commit 153dacc

Browse files
committed
RR feedback
1 parent bf07b18 commit 153dacc

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

source/includes/read/count.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
$client = new MongoDB\Client($uri);
88

99
// start-db-coll
10-
$db = $client->sample_training;
11-
$collection = $db->companies;
10+
$collection = $client->sample_training->companies;
1211
// end-db-coll
1312

1413
// Counts all documents in the collection

source/read/count.txt

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,22 @@ Overview
2121
---------
2222

2323
In this guide, you can learn how to use the {+php-library+} to retrieve an accurate
24-
and estimated count of the number of documents in a collection. The ``MongoDB\Collection::countDocuments()``
25-
method returns the exact number of documents that match a query filter or that exist in
26-
a collection, and the ``MongoDB\Collection::estimatedDocumentCount()`` method returns
27-
the estimated number of documents in a collection.
24+
and estimated count of the number of documents in a collection. The following methods
25+
count documents in a collection:
26+
27+
- ``MongoDB\Collection::countDocuments()``: Returns the exact number of documents that
28+
match a query filter or that exist in a collection
29+
30+
- ``MongoDB\Collection::estimatedDocumentCount()``: Returns the estimated number of documents
31+
in a collection
2832

2933
Sample Data
3034
~~~~~~~~~~~
3135

3236
The examples in this guide use the ``companies`` collection in the ``sample_training``
3337
database from the :atlas:`Atlas sample datasets </sample-data>`. To access this collection
3438
from your PHP application, instantiate a ``MongoDB\Client`` that connects to an Atlas cluster
35-
and assign the following values to your ``db`` and ``collection`` variables:
39+
and assign the following value to your ``collection`` variable:
3640

3741
.. literalinclude:: /includes/read/count.php
3842
:language: php
@@ -80,8 +84,8 @@ Count Specific Documents
8084
To return a count of documents that match specific search criteria, pass a query
8185
filter to the ``countDocuments()`` method.
8286

83-
The following example counts the number of documents that have a ``founded_year``
84-
value of ``2010``:
87+
The following example counts the number of documents in which the value of the
88+
``founded_year`` field is ``2010``:
8589

8690
.. io-code-block::
8791
:copyable:
@@ -101,8 +105,8 @@ Customize Count Behavior
101105
~~~~~~~~~~~~~~~~~~~~~~~~
102106

103107
You can modify the behavior of the ``countDocuments()`` method by
104-
passing an array that specifies option values as a parameter. The
105-
following table describes some options you can set in the array:
108+
passing an array that specifies option values. The following table
109+
describes some options you can set to customize the count operation:
106110

107111
.. list-table::
108112
:widths: 30 70
@@ -164,9 +168,9 @@ Retrieve an Estimated Count
164168
---------------------------
165169

166170
You can retrieve an estimate of the number of documents in a collection by calling
167-
the ``estimatedDocumentCount()`` method. The method estimates the amount of
168-
documents based on collection metadata, which might be faster than performing an
169-
accurate count.
171+
the ``MongoDB\Collection::estimatedDocumentCount()`` method. The method estimates
172+
the amount of documents based on collection metadata, which might be faster than
173+
performing an accurate count.
170174

171175
The following example estimates the number of documents in a collection:
172176

@@ -221,8 +225,8 @@ following table describes the options you can set in the array:
221225
| **Type**: ``MongoDB\Driver\Session``
222226

223227
The following example uses the ``estimatedDocumentCount()`` method to return an
224-
estimate of the number of documents in the collection and instructs the operation
225-
to run for a maximum of ``1000`` milliseconds:
228+
estimate of the number of documents in the collection and sets a timeout of
229+
``1000`` milliseconds on the operation:
226230

227231
.. io-code-block::
228232
:copyable:

0 commit comments

Comments
 (0)