Skip to content

Commit 894051f

Browse files
committed
Specity write options in execute methods, not batch constructors
1 parent bf4ec13 commit 894051f

File tree

4 files changed

+18
-34
lines changed

4 files changed

+18
-34
lines changed

docs/api/MongoDB/Manager.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,15 @@ public function executeQuery($namespace, Query $query, ReadPreference $readPrefe
9494
/**
9595
* @param string $namespace
9696
* @param WriteBatch $batch
97+
* @param array $writeOptions Ordering and write concern options (default: {"ordered": true, "w": 1})
9798
* @return WriteResult
9899
*/
99-
public function executeWrite($namespace, WriteBatch $batch)
100+
public function executeWrite($namespace, WriteBatch $batch, array $writeOptions = null)
100101
{
101102
/* Select writeable server and invoke Server::executeQuery().
102103
*
103-
* Write options are not taken as an argument, since they are specified
104-
* during WriteBatch construction.
104+
* Write options are optional, and will be merged into the default,
105+
* which is {"ordered": true, "w": 1}.
105106
*
106107
* On error, we should consider throwing:
107108
*
@@ -119,12 +120,16 @@ public function executeWrite($namespace, WriteBatch $batch)
119120
*
120121
* @param string $namespace
121122
* @param array|object $document Document to insert
122-
* @param array $writeOptions Write concern options
123+
* @param array $writeOptions Write concern options (default: {"w": 1})
123124
* @return InsertResult
124125
*/
125126
public function executeInsert($namespace, $document, array $writeOptions = null)
126127
{
127-
// Construct and execute an InsertBatch
128+
/* Construct and execute an InsertBatch
129+
*
130+
* Write options are optional, and will be merged into the default,
131+
* which is {"w": 1}.
132+
*/
128133
}
129134

130135
/**
@@ -134,12 +139,15 @@ public function executeInsert($namespace, $document, array $writeOptions = null)
134139
* @param array|object $query Update criteria
135140
* @param array|object $newObj Update modifier or replacement document
136141
* @param array $updateOptions Update options (e.g. "upsert")
137-
* @param array $writeOptions Write concern options
142+
* @param array $writeOptions Write concern options (default: {"w": 1})
138143
* @return UpdateResult
139144
*/
140145
public function executeUpdate($namespace, $query, $newObj, array $updateOptions = null, array $writeOptions = null)
141146
{
142147
/* Construct and execute an UpdateBatch
148+
*
149+
* Write options are optional, and will be merged into the default,
150+
* which is {"w": 1}.
143151
*
144152
* What should be the default value for $options? No multi, no upsert?
145153
*/
@@ -151,12 +159,15 @@ public function executeUpdate($namespace, $query, $newObj, array $updateOptions
151159
* @param string $namespace
152160
* @param array|object $query Deletion criteria
153161
* @param array $deleteOptions Deletion options (e.g. "limit")
154-
* @param array $writeOptions Write concern options
162+
* @param array $writeOptions Write concern options (default: {"w": 1})
155163
* @return DeleteResult
156164
*/
157165
public function executeDelete($namespace, $query, array $deleteOptions = null, array $writeOptions = null)
158166
{
159167
/* Construct and execute an DeleteBatch
168+
*
169+
* Write options are optional, and will be merged into the default,
170+
* which is {"w": 1}.
160171
*
161172
* What should be the default value for $options? No limit?
162173
*/

docs/api/MongoDB/Write/DeleteBatch.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@
88
final class DeleteBatch implements WriteBatch
99
{
1010
private $documents;
11-
private $writeOptions;
12-
13-
/**
14-
* @param array $writeOptions Ordering and write concern options
15-
*/
16-
public function __construct(array $writeOptions)
17-
{
18-
$this->writeOptions = $writeOptions;
19-
}
2011

2112
/**
2213
* @see WriteBatch::add()

docs/api/MongoDB/Write/InsertBatch.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@
88
final class InsertBatch implements WriteBatch
99
{
1010
private $documents;
11-
private $writeOptions;
12-
13-
/**
14-
* @param array $writeOptions Ordering and write concern options
15-
*/
16-
public function __construct(array $writeOptions)
17-
{
18-
$this->writeOptions = $writeOptions;
19-
}
2011

2112
/**
2213
* @see WriteBatch::add()

docs/api/MongoDB/Write/UpdateBatch.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@
88
final class UpdateBatch implements WriteBatch
99
{
1010
private $documents;
11-
private $writeOptions;
12-
13-
/**
14-
* @param array $writeOptions Ordering and write concern options
15-
*/
16-
public function __construct(array $writeOptions)
17-
{
18-
$this->writeOptions = $writeOptions;
19-
}
2011

2112
/**
2213
* @see WriteBatch::add()

0 commit comments

Comments
 (0)