Skip to content

Commit bdec3e1

Browse files
committed
PHPLIB-235: Document write result classes
1 parent 7dc53b8 commit bdec3e1

28 files changed

+1029
-11
lines changed

docs/includes/extracts-error.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ content: |
1010
<mongodb-driver-exception-runtimeexception>` for other errors at the driver
1111
level (e.g. connection errors).
1212
---
13+
ref: error-badmethodcallexception-write-result
14+
content: |
15+
:phpclass:`MongoDB\\Exception\\BadMethodCallException` if this method is
16+
called and the write operation used an unacknowledged :manual:`write concern
17+
</reference/write-concern>`.
18+
---
1319
ref: error-invalidargumentexception
1420
content: |
1521
:phpclass:`MongoDB\\Exception\\InvalidArgumentException` for errors related to

docs/reference.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ Reference
1212
/reference/class/MongoDBDatabase
1313
/reference/class/MongoDBCollection
1414
/reference/class/MongoDBGridFSBucket
15+
/reference/write-result-classes
1516
/reference/exception-classes
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
===========================================
2+
MongoDB\\BulkWriteResult::getDeletedCount()
3+
===========================================
4+
5+
.. default-domain:: mongodb
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 1
11+
:class: singlecol
12+
13+
Definition
14+
----------
15+
16+
.. phpmethod:: MongoDB\\BulkWriteResult::getDeletedCount()
17+
18+
Return the total number of documents that were deleted by all delete
19+
operations in the bulk write.
20+
21+
.. code-block:: php
22+
23+
function getDeletedCount(): integer
24+
25+
This method should only be called if the write was acknowledged.
26+
27+
Return Values
28+
-------------
29+
30+
The total number of documents that were deleted by all delete operations in the
31+
bulk write.
32+
33+
Errors/Exceptions
34+
-----------------
35+
36+
.. include:: /includes/extracts/error-badmethodcallexception-write-result.rst
37+
38+
See Also
39+
--------
40+
41+
- :php:`MongoDB\\Driver\\WriteResult::getDeletedCount()
42+
<manual/en/mongodb-driver-writeresult.getdeletedcount.php>`
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
============================================
2+
MongoDB\\BulkWriteResult::getInsertedCount()
3+
============================================
4+
5+
.. default-domain:: mongodb
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 1
11+
:class: singlecol
12+
13+
Definition
14+
----------
15+
16+
.. phpmethod:: MongoDB\\BulkWriteResult::getInsertedCount()
17+
18+
Return the total number of documents that were inserted by all insert
19+
operations in the bulk write.
20+
21+
.. code-block:: php
22+
23+
function getInsertedCount(): integer
24+
25+
This method should only be called if the write was acknowledged.
26+
27+
Return Values
28+
-------------
29+
30+
The total number of documents that were inserted by all insert operations in the
31+
bulk write.
32+
33+
Errors/Exceptions
34+
-----------------
35+
36+
.. include:: /includes/extracts/error-badmethodcallexception-write-result.rst
37+
38+
See Also
39+
--------
40+
41+
- :php:`MongoDB\\Driver\\WriteResult::getInsertedCount()
42+
<manual/en/mongodb-driver-writeresult.getinsertedcount.php>`
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
==========================================
2+
MongoDB\\BulkWriteResult::getInsertedIds()
3+
==========================================
4+
5+
.. default-domain:: mongodb
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 1
11+
:class: singlecol
12+
13+
Definition
14+
----------
15+
16+
.. phpmethod:: MongoDB\\BulkWriteResult::getInsertedIds()
17+
18+
Return a map of IDs (i.e. ``_id`` field values) for documents that were
19+
inserted by all insert operations in the bulk write.
20+
21+
.. code-block:: php
22+
23+
function getInsertedIds(): array
24+
25+
Since IDs are created by the driver, this method may be called irrespective
26+
of whether the write was acknowledged.
27+
28+
Return Values
29+
-------------
30+
31+
A map of IDs (i.e. ``_id`` field values) for documents that were inserted by all
32+
insert operations in the bulk write.
33+
34+
The index of each ID in the map corresponds to each document's position in the
35+
bulk operation. If a document had an ID prior to inserting (i.e. the driver did
36+
not generate an ID), this will contain its ``_id`` field value. Any
37+
driver-generated ID will be a :php:`MongoDB\\BSON\\ObjectID
38+
<class.mongodb-bson-objectid>` instance.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
===========================================
2+
MongoDB\\BulkWriteResult::getMatchedCount()
3+
===========================================
4+
5+
.. default-domain:: mongodb
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 1
11+
:class: singlecol
12+
13+
Definition
14+
----------
15+
16+
.. phpmethod:: MongoDB\\BulkWriteResult::getMatchedCount()
17+
18+
Return the total number of documents that were matched by all update and
19+
replace operations in the bulk write.
20+
21+
.. code-block:: php
22+
23+
function getMatchedCount(): integer
24+
25+
This method should only be called if the write was acknowledged.
26+
27+
.. note::
28+
29+
If an update/replace operation results in no change to the document
30+
(e.g. setting the value of a field to its current value), the matched
31+
count may be greater than the value returned by
32+
:phpmethod:`getModifiedCount()
33+
<MongoDB\\BulkWriteResult::getModifiedCount()>`.
34+
35+
Return Values
36+
-------------
37+
38+
The total number of documents that were matched by all update and replace
39+
operations in the bulk write.
40+
41+
Errors/Exceptions
42+
-----------------
43+
44+
.. include:: /includes/extracts/error-badmethodcallexception-write-result.rst
45+
46+
See Also
47+
--------
48+
49+
- :phpmethod:`MongoDB\\BulkWriteResult::getModifiedCount()`
50+
- :php:`MongoDB\\Driver\\WriteResult::getMatchedCount()
51+
<manual/en/mongodb-driver-writeresult.getmatchedcount.php>`
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
============================================
2+
MongoDB\\BulkWriteResult::getModifiedCount()
3+
============================================
4+
5+
.. default-domain:: mongodb
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 1
11+
:class: singlecol
12+
13+
Definition
14+
----------
15+
16+
.. phpmethod:: MongoDB\\BulkWriteResult::getModifiedCount()
17+
18+
Return the total number of documents that were modified by all update and
19+
replace operations in the bulk write.
20+
21+
.. code-block:: php
22+
23+
function getModifiedCount(): integer|null
24+
25+
This method should only be called if the write was acknowledged.
26+
27+
.. note::
28+
29+
If an update/replace operation results in no change to the document
30+
(e.g. setting the value of a field to its current value), the modified
31+
count may be less than the value returned by :phpmethod:`getMatchedCount()
32+
<MongoDB\\BulkWriteResult::getMatchedCount()>`.
33+
34+
Return Values
35+
-------------
36+
37+
The total number of documents that were modified by all update and replace
38+
operations in the bulk write.
39+
40+
The modified count is not available on versions of MongoDB before 2.6, which
41+
used the legacy wire protocol version (i.e. ``OP_UPDATE``). If this is the case,
42+
the modified count will be ``null``.
43+
44+
Errors/Exceptions
45+
-----------------
46+
47+
.. include:: /includes/extracts/error-badmethodcallexception-write-result.rst
48+
49+
See Also
50+
--------
51+
52+
- :phpmethod:`MongoDB\\BulkWriteResult::getMatchedCount()`
53+
- :php:`MongoDB\\Driver\\WriteResult::getModifiedCount()
54+
<manual/en/mongodb-driver-writeresult.getmodifiedcount.php>`
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
============================================
2+
MongoDB\\BulkWriteResult::getUpsertedCount()
3+
============================================
4+
5+
.. default-domain:: mongodb
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 1
11+
:class: singlecol
12+
13+
Definition
14+
----------
15+
16+
.. phpmethod:: MongoDB\\BulkWriteResult::getUpsertedCount()
17+
18+
Return the total number of documents that were upserted by all update and
19+
replace operations in the bulk write.
20+
21+
.. code-block:: php
22+
23+
function getUpsertedCount(): integer
24+
25+
This method should only be called if the write was acknowledged.
26+
27+
Return Values
28+
-------------
29+
30+
The total number of documents that were upserted by all update and replace
31+
operations in the bulk write.
32+
33+
Errors/Exceptions
34+
-----------------
35+
36+
.. include:: /includes/extracts/error-badmethodcallexception-write-result.rst
37+
38+
See Also
39+
--------
40+
41+
- :php:`MongoDB\\Driver\\WriteResult::getUpsertedCount()
42+
<manual/en/mongodb-driver-writeresult.getupsertedcount.php>`
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
==========================================
2+
MongoDB\\BulkWriteResult::getUpsertedIds()
3+
==========================================
4+
5+
.. default-domain:: mongodb
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 1
11+
:class: singlecol
12+
13+
Definition
14+
----------
15+
16+
.. phpmethod:: MongoDB\\BulkWriteResult::getUpsertedIds()
17+
18+
Return a map of IDs (i.e. ``_id`` field values) for documents that were
19+
upserted by all update and replace operations in the bulk write.
20+
21+
.. code-block:: php
22+
23+
function getUpsertedIds(): array
24+
25+
Return Values
26+
-------------
27+
28+
A map of IDs (i.e. ``_id`` field values) for documents that were upserted by all
29+
update and replace operations in the bulk write.
30+
31+
The index of each ID in the map corresponds to each document's position in the
32+
bulk operation. If a document had an ID prior to upserting (i.e. the server did
33+
not generate an ID), this will contain its ``_id`` field value. Any
34+
server-generated ID will be a :php:`MongoDB\\BSON\\ObjectID
35+
<class.mongodb-bson-objectid>` instance.
36+
37+
Errors/Exceptions
38+
-----------------
39+
40+
.. include:: /includes/extracts/error-badmethodcallexception-write-result.rst
41+
42+
See Also
43+
--------
44+
45+
- :php:`MongoDB\\Driver\\WriteResult::getUpsertedIds()
46+
<manual/en/mongodb-driver-writeresult.getupsertedids.php>`
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
==========================================
2+
MongoDB\\BulkWriteResult::isAcknowledged()
3+
==========================================
4+
5+
.. default-domain:: mongodb
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 1
11+
:class: singlecol
12+
13+
Definition
14+
----------
15+
16+
.. phpmethod:: MongoDB\\BulkWriteResult::isAcknowledged()
17+
18+
Return whether the write was acknowledged.
19+
20+
.. code-block:: php
21+
22+
function isAcknowledged(): boolean
23+
24+
Return Values
25+
-------------
26+
27+
Return whether the write was acknowledged.
28+
29+
See Also
30+
--------
31+
32+
- :php:`MongoDB\\Driver\\WriteResult::isAcknowledged()
33+
<manual/en/mongodb-driver-writeresult.isacknowledged.php>`
34+
- :manual:`Write Concern </reference/write-concern>` in the MongoDB manual

0 commit comments

Comments
 (0)