Skip to content

Commit 6aaa45d

Browse files
committed
Fix BulkWrite::update() "multi" option usage in docs
Fixes #229
1 parent 5b45b90 commit 6aaa45d

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

docs/bulk.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,25 @@ $jonpall_id = $bulk->insert($jonpall);
5555
* #1 (array|object): search criteria to select the document(s) for updating
5656
* #2 (array|object): replacement document or atomic operations to apply
5757
* #3 (array): update options
58-
* * limit (integer): Updates all matching documents when 0 (false).
59-
* Otherwise, only the first matching document is updated.
58+
* * multi (boolean): Updates all matching documents when true; otherwise,
59+
* only the first matching document is updated. Defaults to false.
6060
* * upsert (boolean): If there is no matching document, create a new
61-
* document from $filter and $update. */
61+
* document from the first two arguments. Defaults to false.
62+
*/
6263
$bulk->update(
6364
["_id" => $hayley_id],
6465
['$set' => ["citizen" => "Iceland"]],
65-
["limit" => 1, "upsert" => false]
66+
["multi" => false, "upsert" => false]
6667
);
6768
$bulk->update(
6869
["citizen" => "Iceland"],
6970
['$set' => ["viking" => true]],
70-
["limit" => 0, "upsert" => false]
71+
["multi" => true, "upsert" => false]
7172
);
7273
$bulk->update(
7374
["name" => "Chuck Norris"],
7475
['$set' => ["viking" => false]],
75-
["limit" => 1, "upsert" => true]
76+
["multi" => false, "upsert" => true]
7677
];
7778

7879
?>

docs/crud.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,20 @@ try {
9494

9595
// Specify the search criteria and update operations (or replacement document)
9696
$filter = ["hello" => "world"];
97-
$update = ['$set' => ["hello" => "wonderful world"]];
97+
$newObj = ['$set' => ["hello" => "wonderful world"]];
9898

9999
/* Specify some command options for the update:
100100
*
101-
* * limit (integer): Updates all matching documents when 0 (false). Otherwise,
102-
* only the first matching document is updated.
101+
* * multi (boolean): Updates all matching documents when true; otherwise, only
102+
* the first matching document is updated. Defaults to false.
103103
* * upsert (boolean): If there is no matching document, create a new document
104-
* from $filter and $update. */
105-
$options = ["limit" => 1, "upsert" => false];
104+
* from $filter and $newObj. Defaults to false.
105+
*/
106+
$options = ["multi" => true, "upsert" => false];
106107

107108
// Create a bulk write object and add our update operation
108109
$bulk = new MongoDB\Driver\BulkWrite;
109-
$bulk->update($filter, $update, $options);
110+
$bulk->update($filter, $newObj, $options);
110111

111112
try {
112113
/* Specify the full namespace as the first argument, followed by the bulk

0 commit comments

Comments
 (0)