Skip to content

Commit 57541f6

Browse files
committed
Merged pull request #542
2 parents f7d697c + ca6570e commit 57541f6

7 files changed

+195
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
source:
2+
file: apiargs-MongoDBCollection-common-option.yaml
3+
ref: collation
4+
---
5+
arg_name: option
6+
name: hint
7+
type: string|array|object
8+
description: |
9+
The index to use. Specify either the index name as a string or the index key
10+
pattern as a document. If specified, then the query system will only consider
11+
plans using the hinted index.
12+
interface: phpmethod
13+
operation: ~
14+
optional: true
15+
---
16+
arg_name: option
17+
name: limit
18+
type: integer
19+
description: |
20+
The maximum number of matching documents to return.
21+
interface: phpmethod
22+
operation: ~
23+
optional: true
24+
---
25+
source:
26+
file: apiargs-common-option.yaml
27+
ref: maxTimeMS
28+
---
29+
source:
30+
file: apiargs-MongoDBCollection-common-option.yaml
31+
ref: readConcern
32+
---
33+
source:
34+
file: apiargs-MongoDBCollection-common-option.yaml
35+
ref: readPreference
36+
---
37+
source:
38+
file: apiargs-common-option.yaml
39+
ref: session
40+
---
41+
arg_name: option
42+
name: skip
43+
type: integer
44+
description: |
45+
The number of matching documents to skip before returning results.
46+
interface: phpmethod
47+
operation: ~
48+
optional: true
49+
...
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
source:
2+
file: apiargs-MongoDBCollection-common-param.yaml
3+
ref: $filter
4+
optional: true
5+
replacement:
6+
action: " to count"
7+
---
8+
source:
9+
file: apiargs-common-param.yaml
10+
ref: $options
11+
...
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
source:
2+
file: apiargs-common-option.yaml
3+
ref: maxTimeMS
4+
---
5+
source:
6+
file: apiargs-MongoDBCollection-common-option.yaml
7+
ref: readConcern
8+
---
9+
source:
10+
file: apiargs-MongoDBCollection-common-option.yaml
11+
ref: readPreference
12+
---
13+
source:
14+
file: apiargs-common-option.yaml
15+
ref: session
16+
...
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source:
2+
file: apiargs-common-param.yaml
3+
ref: $options
4+
...

source/reference/class/MongoDBCollection.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Methods
6363
/reference/method/MongoDBCollection-aggregate
6464
/reference/method/MongoDBCollection-bulkWrite
6565
/reference/method/MongoDBCollection-count
66+
/reference/method/MongoDBCollection-countDocuments
6667
/reference/method/MongoDBCollection-createIndex
6768
/reference/method/MongoDBCollection-createIndexes
6869
/reference/method/MongoDBCollection-deleteMany
@@ -71,6 +72,7 @@ Methods
7172
/reference/method/MongoDBCollection-drop
7273
/reference/method/MongoDBCollection-dropIndex
7374
/reference/method/MongoDBCollection-dropIndexes
75+
/reference/method/MongoDBCollection-estimatedDocumentCount
7476
/reference/method/MongoDBCollection-explain
7577
/reference/method/MongoDBCollection-find
7678
/reference/method/MongoDBCollection-findOne
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
=====================================
2+
MongoDB\\Collection::countDocuments()
3+
=====================================
4+
5+
.. versionadded:: 1.4
6+
7+
.. default-domain:: mongodb
8+
9+
.. contents:: On this page
10+
:local:
11+
:backlinks: none
12+
:depth: 1
13+
:class: singlecol
14+
15+
Definition
16+
----------
17+
18+
.. phpmethod:: MongoDB\\Collection::countDocuments()
19+
20+
Count the number of documents that match the filter criteria.
21+
22+
.. code-block:: php
23+
24+
function countDocuments($filter = [], array $options = []): integer
25+
26+
This method has the following parameters:
27+
28+
.. include:: /includes/apiargs/MongoDBCollection-method-countDocuments-param.rst
29+
30+
The ``$options`` parameter supports the following options:
31+
32+
.. include:: /includes/apiargs/MongoDBCollection-method-countDocuments-option.rst
33+
34+
Return Values
35+
-------------
36+
37+
The number of documents matching the filter criteria.
38+
39+
Errors/Exceptions
40+
-----------------
41+
42+
.. include:: /includes/extracts/error-unexpectedvalueexception.rst
43+
.. include:: /includes/extracts/error-unsupportedexception.rst
44+
.. include:: /includes/extracts/error-invalidargumentexception.rst
45+
.. include:: /includes/extracts/error-driver-runtimeexception.rst
46+
47+
Behavior
48+
--------
49+
50+
.. include:: /includes/extracts/note-bson-comparison.rst
51+
52+
Internally, this method uses the ``$group`` aggregation pipeline operator to
53+
obtain the result. If a ``filter`` parameter is given, this is converted into
54+
a ``$match`` pipeline operator. Optional ``skip`` and ``limit`` stages are
55+
added between ``$match`` and ``group`` if present in the options.
56+
57+
.. todo: add output and examples
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
=============================================
2+
MongoDB\\Collection::estimatedDocumentCount()
3+
=============================================
4+
5+
.. versionadded:: 1.4
6+
7+
.. default-domain:: mongodb
8+
9+
.. contents:: On this page
10+
:local:
11+
:backlinks: none
12+
:depth: 1
13+
:class: singlecol
14+
15+
Definition
16+
----------
17+
18+
.. phpmethod:: MongoDB\\Collection::estimatedDocumentCount()
19+
20+
Gets an estimated number of documents in the collection using collection metadata.
21+
22+
.. code-block:: php
23+
24+
function countDocuments(array $options = []): integer
25+
26+
This method has the following parameters:
27+
28+
.. include:: /includes/apiargs/MongoDBCollection-method-estimateDocumentCount-param.rst
29+
30+
The ``$options`` parameter supports the following options:
31+
32+
.. include:: /includes/apiargs/MongoDBCollection-method-estimateDocumentCount-option.rst
33+
34+
Return Values
35+
-------------
36+
37+
An estimated number of documents in the collection.
38+
39+
Errors/Exceptions
40+
-----------------
41+
42+
.. include:: /includes/extracts/error-unexpectedvalueexception.rst
43+
.. include:: /includes/extracts/error-unsupportedexception.rst
44+
.. include:: /includes/extracts/error-invalidargumentexception.rst
45+
.. include:: /includes/extracts/error-driver-runtimeexception.rst
46+
47+
Behavior
48+
--------
49+
50+
.. include:: /includes/extracts/note-bson-comparison.rst
51+
52+
See Also
53+
--------
54+
55+
- :manual:`count </reference/command/count>` command reference in the MongoDB
56+
manual

0 commit comments

Comments
 (0)