Skip to content

Commit c1003b2

Browse files
rustagirnlarewrachel-macknorareidyshuangela
authored
DOCSP-50294: V2.1 Release (#256)
* DOCSP-44581: v2 release (#234) * DOCSP-44581: v2 release * small fix * Add missing meta descriptions (#235) * Add missing meta descriptions * Apply suggestions from code review --------- Co-authored-by: Rachel Mackintosh <[email protected]> * DOCSP-48761: docker note (#237) * DOCSP-48100: Consolidate minor versions (#240) * DOCSP-48100: Consolidate minor versions * edits * remove old redirects * AB feedback * edit * DOCSP-48718-update-credentials (#247) * update username and password * misspelling * redirects * pre-standardization redirects * upgrade composer package vs * DOCSP-49150: bulkWrite docs + api (#250) * DOCSP-49150: bulkWrite docs + api * first pass fixes * JT PR fixes 1 * upgrade composer package vs * JT PR fixes 2 * small fix * JT PR fixes 3 * remove reference to writeconcern option * add return values sections * object -> instance * NR PR fixes 1 * returns -> throws * DOCSP-50022: remove eol server version mentions (#253) * DOCSP-50022: remove eol server version mentions * consolidate compat table rows * DOCSP-50155 - EOL MongoDB 4.0 (#252) * eol v4.0 * update compat * DOCSP-50294: v2.1 release (#255) --------- Co-authored-by: Nick Larew <[email protected]> Co-authored-by: Rachel Mackintosh <[email protected]> Co-authored-by: Nora Reidy <[email protected]> Co-authored-by: shuangela <[email protected]> Co-authored-by: Mike Woofter <[email protected]>
1 parent 061b622 commit c1003b2

30 files changed

+1463
-111
lines changed

composer/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"name": "mongodb/docs-php-library",
33
"description": "MongoDB PHP Library Documentation",
44
"require": {
5-
"ext-mongodb": "^1.20",
6-
"mongodb/mongodb": "^1.20"
5+
"ext-mongodb": "^2.1",
6+
"mongodb/mongodb": "^2.1"
77
},
88
"require-dev": {
99
"doctrine/coding-standard": "^12.0",

config/redirects

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
1-
define: base https://www.mongodb.com/docs/php-library
21
define: prefix docs/php-library
3-
raw: ${prefix}/ -> ${base}/current
4-
define: versions v1.16 v1.17 v1.18 v1.19 v1.20 v1.21 v2.0 master
2+
define: base https://www.mongodb.com/${prefix}
3+
define: versions v1.16 v1.17 v1.18 v1.19 v1.20 v1.21 v1.x v2.0 v2.x master
54

65
symlink: upcoming -> master
7-
symlink: current -> v2.0
6+
symlink: current -> v2.x
7+
8+
raw: ${prefix}/ -> ${base}/current/
9+
raw: ${prefix}/stable -> ${base}/current/
10+
11+
# consolidation redirects
12+
[*-v1.21]: ${prefix}/${version}/ -> ${base}/v1.x/
13+
[v2.0]: ${prefix}/${version}/ -> ${base}/v2.x/
814

915
# general redirects
10-
[v1.17-v1.19]: ${prefix}/${version}/tutorial/client-side-encryption/ -> ${base}/${version}/tutorial/encryption/
11-
[v1.16]: ${prefix}/${version}/tutorial/encryption/ -> ${base}/${version}/
12-
[v1.20-*]: ${prefix}/${version}/get-started/connect-to-mongodb -> ${base}/${version}/get-started/run-sample-query/
16+
[v1.17-v1.19]: ${prefix}/${version}/tutorial/client-side-encryption/ -> ${base}/${version}/security/in-use-encryption/
17+
[v1.16]: ${prefix}/${version}/tutorial/encryption/ -> ${base}/${version}/security/in-use-encryption/
18+
[v1.20-*]: ${prefix}/${version}/get-started/connect-to-mongodb -> ${base}/${version}/get-started/#run-a-sample-query/
1319
[*-v1.20]: ${prefix}/${version}/aggregation/atlas-search -> ${base}/${version}/aggregation/
1420
[*-v1.20]: ${prefix}/${version}/aggregation/vector-search -> ${base}/${version}/aggregation/
1521
[*-v1.20]: ${prefix}/${version}/builders -> ${base}/${version}/
1622

1723
# standardization redirects
1824

1925
# redirects in standardized docs
20-
[v1.20-*]: ${prefix}/${version}/tutorial/install-php-library/ -> ${base}/${version}/get-started/download-and-install/
26+
[v1.20-*]: ${prefix}/${version}/tutorial/install-php-library/ -> ${base}/${version}/get-started/
2127
[v1.20-*]: ${prefix}/${version}/tutorial/connecting/ -> ${base}/${version}/connect/
2228
[v1.20-*]: ${prefix}/${version}/tutorial/server-selection/ -> ${base}/${version}/monitoring/cluster-monitoring/
2329
[v1.20-*]: ${prefix}/${version}/tutorial/crud/ -> ${base}/${version}/read/
@@ -37,20 +43,20 @@ symlink: current -> v2.0
3743

3844
# redirects in old docs
3945
# note: this mapping does not account for all of the new pages
40-
[*-v1.19]: ${prefix}/${version}/get-started/download-and-install/ -> ${base}/${version}/tutorial/install-php-library/
41-
[*-v1.19]: ${prefix}/${version}/connect/ -> ${base}/${version}/tutorial/connecting/
42-
[*-v1.19]: ${prefix}/${version}/monitoring/cluster-monitoring/ -> ${base}/${version}/tutorial/server-selection/
43-
[*-v1.19]: ${prefix}/${version}/read/ -> ${base}/${version}/tutorial/crud/
44-
[*-v1.19]: ${prefix}/${version}/data-formats/codecs/ -> ${base}/${version}/tutorial/codecs/
45-
[*-v1.19]: ${prefix}/${version}/run-command/ -> ${base}/${version}/tutorial/commands/
46-
[*-v1.19]: ${prefix}/${version}/data-formats/custom-types/ -> ${base}/${version}/tutorial/custom-types/
47-
[*-v1.19]: ${prefix}/${version}/data-formats/decimal128/ -> ${base}/${version}/tutorial/decimal128/
48-
[*-v1.19]: ${prefix}/${version}/security/in-use-encryption/ -> ${base}/${version}/tutorial/encryption/
49-
[*-v1.19]: ${prefix}/${version}/write/gridfs/ -> ${base}/${version}/tutorial/gridfs/
50-
[*-v1.19]: ${prefix}/${version}/indexes/ -> ${base}/${version}/tutorial/indexes/
51-
[*-v1.19]: ${prefix}/${version}/read/cursor/ -> ${base}/${version}/tutorial/tailable-cursor/
52-
[*-v1.19]: ${prefix}/${version}/data-formats/modeling-bson-data/ -> ${base}/${version}/tutorial/modeling-bson-data/
53-
[*-v1.19]: ${prefix}/${version}/stable-api/ -> ${base}/${version}/tutorial/stable-api/
54-
[*-v1.19]: ${prefix}/${version}/whats-new/ -> ${base}/${version}/
55-
[*-v1.19]: ${prefix}/${version}/aws-lambda/ -> ${base}/${version}/tutorial/aws-lambda/
56-
46+
[*-v1.19]: ${prefix}/${version}/tutorial/install-php-library/ -> ${base}/v1.x/get-started/
47+
[*-v1.19]: ${prefix}/${version}/tutorial/connecting/ -> ${base}/v1.x/connect/
48+
[*-v1.19]: ${prefix}/${version}/tutorial/server-selection/ -> ${base}/v1.x/monitoring/cluster-monitoring/
49+
[*-v1.19]: ${prefix}/${version}/tutorial/crud/ -> ${base}/v1.x/read/
50+
[*-v1.19]: ${prefix}/${version}/tutorial/codecs/ -> ${base}/v1.x/data-formats/codecs/
51+
[*-v1.19]: ${prefix}/${version}/tutorial/collation/ -> ${base}/v1.x/
52+
[*-v1.19]: ${prefix}/${version}/tutorial/commands/ -> ${base}/v1.x/run-command/
53+
[*-v1.19]: ${prefix}/${version}/tutorial/custom-types/ -> ${base}/v1.x/data-formats/custom-types/
54+
[*-v1.19]: ${prefix}/${version}/tutorial/decimal128/ -> ${base}/v1.x/data-formats/decimal128/
55+
[*-v1.19]: ${prefix}/${version}/tutorial/encryption/ -> ${base}/v1.x/security/in-use-encryption/
56+
[*-v1.19]: ${prefix}/${version}/tutorial/gridfs/ -> ${base}/v1.x/write/gridfs/
57+
[*-v1.19]: ${prefix}/${version}/tutorial/indexes/ -> ${base}/v1.x/indexes/
58+
[*-v1.19]: ${prefix}/${version}/tutorial/tailable-cursor/ -> ${base}/v1.x/read/cursor/
59+
[*-v1.19]: ${prefix}/${version}/tutorial/example-data/ -> ${base}/v1.x/
60+
[*-v1.19]: ${prefix}/${version}/tutorial/modeling-bson-data/ -> ${base}/v1.x/data-formats/modeling-bson-data/
61+
[*-v1.19]: ${prefix}/${version}/tutorial/stable-api/ -> ${base}/v1.x/stable-api/
62+
[*-v1.19]: ${prefix}/${version}/tutorial/aws-lambda/ -> ${base}/v1.x/aws-lambda/

snooty.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ intersphinx = [
99

1010
toc_landing_pages = [
1111
"/reference/class/MongoDBClient",
12+
"/reference/class/MongoDBClientBulkWrite",
1213
"/reference/class/MongoDBCollection",
1314
"/reference/class/MongoDBDatabase",
1415
"/reference/class/MongoDBGridFSBucket",
@@ -38,7 +39,7 @@ php-library = "MongoDB PHP Library"
3839

3940
[constants]
4041
php-library = "MongoDB PHP Library"
41-
version = "2.0"
42+
version = "2.1"
4243
source-gh-branch = "v2.x"
4344
full-version = "{+version+}.0"
4445
extension-short = "PHP extension"

source/includes/extracts-bulkwriteexception.yaml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
ref: bulkwriteexception-result
22
content: |
33
If a :php:`MongoDB\Driver\Exception\BulkWriteException
4-
<mongodb-driver-exception-bulkwriteexception>` is thrown, users should call
5-
:php:`getWriteResult() <mongodb-driver-writeexception.getwriteresult>` and
4+
<mongodb-driver-exception-bulkwriteexception>` is thrown, you can call
5+
:php:`getWriteResult() <mongodb-driver-bulkwriteexception.getwriteresult>` and
66
inspect the returned :php:`MongoDB\Driver\WriteResult
77
<mongodb-driver-writeresult>` object to determine the nature of the error.
88
@@ -11,11 +11,22 @@ content: |
1111
too long). Alternatively, a write operation may have failed outright (e.g.
1212
unique key violation).
1313
---
14+
ref: bulkwriteexception-client-result
15+
content: |
16+
If a :php:`MongoDB\Driver\Exception\BulkWriteCommandException
17+
<mongodb-driver-exception-bulkwritecommandexception>` is thrown, you can call
18+
:php:`getWriteErrors() <mongodb-driver-bulkwritecommandexception.getwriteerrors>` and
19+
inspect the information in the returned array to determine the nature of the error.
20+
21+
For example, a write operation may have been successfully applied to the
22+
primary server but failed to satisfy the write concern. Alternatively, a
23+
write operation may have failed outright, for example for violating the
24+
unique key constraint.
25+
---
1426
ref: bulkwriteexception-ordered
1527
content: |
16-
In the case of a bulk write, the result may indicate multiple successful write
28+
In the case of a bulk write, the result might indicate multiple successful write
1729
operations and/or errors. If the ``ordered`` option is ``true``, some
1830
operations may have succeeded before the first error was encountered and the
1931
exception thrown. If the ``ordered`` option is ``false``, multiple errors may
2032
have been encountered.
21-
...

source/includes/extracts-error.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@ ref: error-driver-bulkwriteexception
22
content: |
33
:php:`MongoDB\Driver\Exception\BulkWriteException
44
<mongodb-driver-exception-bulkwriteexception>` for errors related to the write
5-
operation. Users should inspect the value returned by :php:`getWriteResult()
6-
<mongodb-driver-writeexception.getwriteresult>` to determine the nature of the
5+
operation. You can inspect the value returned by :php:`getWriteResult()
6+
<mongodb-driver-bulkwriteexception.getwriteresult>` to determine the nature of the
7+
error.
8+
---
9+
ref: error-driver-client-bulkwriteexception
10+
content: |
11+
:php:`MongoDB\Driver\Exception\BulkWriteCommandException
12+
<mongodb-driver-exception-bulkwritecommandexception>` for errors related to the write
13+
operation. You can inspect the value returned by :php:`getWriteErrors()
14+
<mongodb-driver-bulkwritecommandexception.getwriteerrors>` to determine the nature of the
715
error.
816
---
917
ref: error-driver-invalidargumentexception
@@ -49,4 +57,3 @@ ref: error-gridfs-corruptfileexception
4957
content: |
5058
:phpclass:`MongoDB\GridFS\Exception\CorruptFileException` if the file's
5159
metadata or chunk documents contain unexpected or invalid data.
52-
...

source/includes/language-compatibility-table-php.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
- PHP 7.3
1414
- PHP 7.2
1515

16-
* - ext + lib 1.21 to 2.0
16+
* - ext + lib 1.21 to 2.1
1717
- ✓
1818
- ✓
1919
- ✓

source/includes/mongodb-compatibility-table-php.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
- MongoDB 7.0
99
- MongoDB 6.0
1010

11-
* - ext + lib 1.20 to 2.0
11+
* - ext + lib 1.20 to 2.1
1212
- ✓
1313
- ✓
1414
- ✓

source/includes/write/bulk-write.php

Lines changed: 122 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,22 @@
55
$uri = getenv('MONGODB_URI') ?: throw new RuntimeException('Set the MONGODB_URI variable to your Atlas URI that connects to the sample dataset');
66
$client = new MongoDB\Client($uri);
77

8-
// start-db-coll
9-
$collection = $client->sample_restaurants->restaurants;
10-
// end-db-coll
11-
128
// start-run-bulk
13-
$result = $collection->bulkWrite(
9+
$restaurantCollection = $client->sample_restaurants->restaurants;
10+
11+
$result = $restaurantCollection->bulkWrite(
1412
[
1513
[
1614
'insertOne' => [
17-
['name' => 'Mongo\'s Deli'],
18-
['cuisine' => 'Sandwiches'],
19-
['borough' => 'Manhattan'],
20-
['restaurant_id' => '1234'],
15+
['name' => 'Mongo\'s Deli'],
16+
['cuisine' => 'Sandwiches'],
17+
['borough' => 'Manhattan'],
18+
['restaurant_id' => '1234'],
2119
],
2220
],
2321
[
2422
'updateOne' => [
25-
['name' => 'Mongo\'s Deli'],
23+
['name' => 'Mongo\'s Deli'],
2624
['$set' => ['cuisine' => 'Sandwiches and Salads']],
2725
],
2826
],
@@ -36,14 +34,14 @@
3634
// end-run-bulk
3735

3836
// start-bulk-options
39-
$result = $collection->bulkWrite(
37+
$result = $restaurantCollection->bulkWrite(
4038
[
4139
[
4240
'insertOne' => [
43-
['name' => 'Mongo\'s Pizza'],
44-
['cuisine' => 'Italian'],
45-
['borough' => 'Queens'],
46-
['restaurant_id' => '5678'],
41+
['name' => 'Mongo\'s Pizza'],
42+
['cuisine' => 'Italian'],
43+
['borough' => 'Queens'],
44+
['restaurant_id' => '5678'],
4745
],
4846
],
4947
[
@@ -55,3 +53,112 @@
5553
['ordered' => false]
5654
);
5755
// end-bulk-options
56+
57+
// start-bulk-client-insert-one
58+
$restaurantCollection = $client->sample_restaurants->restaurants;
59+
$movieCollection = $client->sample_mflix->movies;
60+
61+
$bulkWrite = MongoDB\ClientBulkWrite::createWithCollection($restaurantCollection);
62+
$bulkWrite->insertOne(['name' => 'Mongo Deli', 'cuisine' => 'Sandwiches']);
63+
64+
$bulkWrite = $bulkWrite->withCollection($movieCollection);
65+
$bulkWrite->insertOne(['title' => 'The Green Ray', 'year' => 1986]);
66+
// end-bulk-client-insert-one
67+
68+
// start-bulk-client-update-one
69+
$restaurantCollection = $client->sample_restaurants->restaurants;
70+
$bulkWrite = MongoDB\ClientBulkWrite::createWithCollection($restaurantCollection);
71+
72+
$bulkWrite->updateOne(
73+
['name' => 'Dandelion Bakery'],
74+
['$set' => ['grade' => 'B+']],
75+
['upsert' => true],
76+
);
77+
// end-bulk-client-update-one
78+
79+
// start-bulk-client-update-many
80+
$restaurantCollection = $client->sample_restaurants->restaurants;
81+
$bulkWrite = MongoDB\ClientBulkWrite::createWithCollection($restaurantCollection);
82+
83+
$bulkWrite->updateMany(
84+
['name' => 'Starbucks'],
85+
['$set' => ['cuisine' => 'Coffee (Chain)']],
86+
);
87+
// end-bulk-client-update-many
88+
89+
// start-bulk-client-replace-one
90+
$restaurantCollection = $client->sample_restaurants->restaurants;
91+
$bulkWrite = MongoDB\ClientBulkWrite::createWithCollection($restaurantCollection);
92+
93+
$bulkWrite->replaceOne(
94+
['name' => 'Dandelion Bakery'],
95+
['name' => 'Flower Patisserie', 'cuisine' => 'Bakery & Cafe'],
96+
);
97+
// end-bulk-client-replace-one
98+
99+
// start-bulk-client-delete-one
100+
$restaurantCollection = $client->sample_restaurants->restaurants;
101+
$bulkWrite = MongoDB\ClientBulkWrite::createWithCollection($restaurantCollection);
102+
103+
$bulkWrite->deleteOne(
104+
['borough' => 'Queens'],
105+
);
106+
// end-bulk-client-delete-one
107+
108+
// start-bulk-client-delete-many
109+
$restaurantCollection = $client->sample_restaurants->restaurants;
110+
$bulkWrite = MongoDB\ClientBulkWrite::createWithCollection($restaurantCollection);
111+
112+
$bulkWrite->deleteMany(
113+
['name' => ['$regex' => 'p{2,}']],
114+
);
115+
// end-bulk-client-delete-many
116+
117+
// start-bulk-client
118+
$restaurantCollection = $client->sample_restaurants->restaurants;
119+
$movieCollection = $client->sample_mflix->movies;
120+
// Creates the bulk write command and sets the target namespace.
121+
$bulkWrite = MongoDB\ClientBulkWrite::createWithCollection($restaurantCollection);
122+
// Specifies insertion of one document.
123+
$bulkWrite->insertOne(['name' => 'Mongo Deli', 'cuisine' => 'Sandwiches']);
124+
// Specifies a `$set` update to one document with the upsert option
125+
// enabled.
126+
$bulkWrite->updateOne(
127+
['name' => 'Dandelion Bakery'],
128+
['$set' => ['grade' => 'B+']],
129+
['upsert' => true],
130+
);
131+
// Changes the target namespace.
132+
$bulkWrite = $bulkWrite->withCollection($movieCollection);
133+
// Specifies insertion of one document.
134+
$bulkWrite->insertOne(['title' => 'The Green Ray', 'year' => 1986]);
135+
// Specifies deletion of documents in which `title` has two consective
136+
// 'd' characters.
137+
$bulkWrite->deleteMany(
138+
['title' => ['$regex' => 'd{2,}']],
139+
);
140+
// Specifies replacement of one document.
141+
$bulkWrite->replaceOne(
142+
['runtime' => ['$gte' => 200]],
143+
['title' => 'Seven Samurai', 'runtime' => 203],
144+
);
145+
146+
// Performs the bulk write operation.
147+
$result = $client->bulkWrite($bulkWrite);
148+
// Prints a summary of results.
149+
echo 'Inserted documents: ', $result->getInsertedCount(), PHP_EOL;
150+
echo 'Modified documents: ', $result->getModifiedCount(), PHP_EOL;
151+
echo 'Deleted documents: ', $result->getDeletedCount(), PHP_EOL;
152+
// end-bulk-client
153+
154+
// start-bulk-client-options
155+
$bulkWrite = MongoDB\ClientBulkWrite::createWithCollection(
156+
$restaurantCollection,
157+
['ordered' => false]
158+
);
159+
// end-bulk-client-options
160+
161+
// start-bulk-client-unordered-behavior
162+
$bulkWrite->insertOne(['_id' => 4045, 'title' => 'The Green Ray']);
163+
$bulkWrite->deleteOne(['_id' => 4045]);
164+
// end-bulk-client-unordered-behavior

source/reference.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ API Documentation
1111

1212
BSON </reference/bson>
1313
MongoDB\Client </reference/class/MongoDBClient>
14+
MongoDB\ClientBulkWrite </reference/class/MongoDBClientBulkWrite>
1415
MongoDB\Database </reference/class/MongoDBDatabase>
1516
MongoDB\Collection </reference/class/MongoDBCollection>
1617
MongoDB\GridFS\Bucket </reference/class/MongoDBGridFSBucket>

0 commit comments

Comments
 (0)