Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-php-library
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
mongo-php-library
Commits
1515b024
Commit
1515b024
authored
Jun 27, 2018
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-364: Deprecate count() and elaborate on count method behaviors
parent
34376883
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
5 deletions
+28
-5
MongoDBCollection-count.txt
docs/reference/method/MongoDBCollection-count.txt
+16
-2
MongoDBCollection-countDocuments.txt
docs/reference/method/MongoDBCollection-countDocuments.txt
+7
-2
MongoDBCollection-estimatedDocumentCount.txt
...rence/method/MongoDBCollection-estimatedDocumentCount.txt
+5
-1
No files found.
docs/reference/method/MongoDBCollection-count.txt
View file @
1515b024
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
MongoDB\\Collection::count()
MongoDB\\Collection::count()
============================
============================
.. deprecated:: 1.4
.. default-domain:: mongodb
.. default-domain:: mongodb
.. contents:: On this page
.. contents:: On this page
...
@@ -45,12 +47,24 @@ Errors/Exceptions
...
@@ -45,12 +47,24 @@ Errors/Exceptions
Behavior
Behavior
--------
--------
.. include:: /includes/extracts/note-bson-comparison.rst
This method is deprecated and cannot be executed within a transaction. It has
always been implemented using the :manual:`count </reference/command/count>`
command. The behavior of the ``count`` command differs depending on the options
passed to it and may or may not provide an accurate count. When no query filter
is provided, the ``count`` command provides an estimate using collection
metadata. Even when provided with a query filter the ``count`` command can
return inaccurate results with a sharded cluster if orphaned documents exist or
if a chunk migration is in progress. The
:phpmethod:`MongoDB\\Collection::countDocuments()` method avoids these sharded
cluster problems entirely when used with MongoDB 3.6+, and when a primary read
preference with older sharded clusters.
..
todo: add output and examples
..
include:: /includes/extracts/note-bson-comparison.rst
See Also
See Also
--------
--------
- :manual:`count </reference/command/count>` command reference in the MongoDB
- :manual:`count </reference/command/count>` command reference in the MongoDB
manual
manual
- :phpmethod:`MongoDB\\Collection::countDocuments()`
- :phpmethod:`MongoDB\\Collection::estimatedDocumentCount()`
docs/reference/method/MongoDBCollection-countDocuments.txt
View file @
1515b024
...
@@ -47,8 +47,6 @@ Errors/Exceptions
...
@@ -47,8 +47,6 @@ Errors/Exceptions
Behavior
Behavior
--------
--------
.. include:: /includes/extracts/note-bson-comparison.rst
Internally, this method uses the ``$group`` aggregation pipeline operator to
Internally, this method uses the ``$group`` aggregation pipeline operator to
obtain the result. If a ``filter`` parameter is given, this is converted into
obtain the result. If a ``filter`` parameter is given, this is converted into
a ``$match`` pipeline operator. Optional ``$skip`` and ``$limit`` stages are
a ``$match`` pipeline operator. Optional ``$skip`` and ``$limit`` stages are
...
@@ -73,4 +71,11 @@ Consider the following alternatives to these restricted operators:
...
@@ -73,4 +71,11 @@ Consider the following alternatives to these restricted operators:
* - :query:`$where`
* - :query:`$where`
- :query:`$expr` (requires MongoDB 3.6+)
- :query:`$expr` (requires MongoDB 3.6+)
.. include:: /includes/extracts/note-bson-comparison.rst
.. todo: add output and examples
.. todo: add output and examples
See Also
--------
- :phpmethod:`MongoDB\\Collection::estimatedDocumentCount()`
docs/reference/method/MongoDBCollection-estimatedDocumentCount.txt
View file @
1515b024
...
@@ -47,10 +47,14 @@ Errors/Exceptions
...
@@ -47,10 +47,14 @@ Errors/Exceptions
Behavior
Behavior
--------
--------
.. include:: /includes/extracts/note-bson-comparison.rst
This method returns an estimate of the count of documents in the collection
using collection metadata, rather than counting the documents or consulting an
index. This method does not take a ``session`` option and cannot be executed
within a transaction.
See Also
See Also
--------
--------
- :manual:`count </reference/command/count>` command reference in the MongoDB
- :manual:`count </reference/command/count>` command reference in the MongoDB
manual
manual
- :phpmethod:`MongoDB\\Collection::countDocuments()`
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment