Commit 266b7e9a authored by Hannes Magnusson's avatar Hannes Magnusson

PHPLIB-62: Its called BulkWrite now

parent bb7452f4
...@@ -7,7 +7,7 @@ use MongoDB\Driver\Manager; ...@@ -7,7 +7,7 @@ use MongoDB\Driver\Manager;
use MongoDB\Driver\Query; use MongoDB\Driver\Query;
use MongoDB\Driver\ReadPreference; use MongoDB\Driver\ReadPreference;
use MongoDB\Driver\Result; use MongoDB\Driver\Result;
use MongoDB\Driver\WriteBatch; use MongoDB\Driver\BulkWrite;
use MongoDB\Driver\WriteConcern; use MongoDB\Driver\WriteConcern;
class Collection class Collection
...@@ -287,7 +287,7 @@ class Collection ...@@ -287,7 +287,7 @@ class Collection
} }
/** /**
* Adds a full set of write operations into a batch and executes it * Adds a full set of write operations into a bulk and executes it
* *
* The syntax of the $bulk array is: * The syntax of the $bulk array is:
* $bulk = [ * $bulk = [
...@@ -337,7 +337,7 @@ class Collection ...@@ -337,7 +337,7 @@ class Collection
{ {
$options = array_merge($this->getBulkOptions(), $options); $options = array_merge($this->getBulkOptions(), $options);
$batch = new WriteBatch($options["ordered"]); $bulk = new BulkWrite($options["ordered"]);
foreach ($bulk as $n => $op) { foreach ($bulk as $n => $op) {
foreach ($op as $opname => $args) { foreach ($op as $opname => $args) {
...@@ -347,7 +347,7 @@ class Collection ...@@ -347,7 +347,7 @@ class Collection
switch ($opname) { switch ($opname) {
case "insertOne": case "insertOne":
$batch->insert($args[0]); $bulk->insert($args[0]);
break; break;
case "updateMany": case "updateMany":
...@@ -356,7 +356,7 @@ class Collection ...@@ -356,7 +356,7 @@ class Collection
} }
$options = array_merge($this->getWriteOptions(), isset($args[2]) ? $args[2] : array(), array("limit" => 0)); $options = array_merge($this->getWriteOptions(), isset($args[2]) ? $args[2] : array(), array("limit" => 0));
$batch->update($args[0], $args[1], $options); $bulk->update($args[0], $args[1], $options);
break; break;
case "updateOne": case "updateOne":
...@@ -368,7 +368,7 @@ class Collection ...@@ -368,7 +368,7 @@ class Collection
throw new \InvalidArgumentException("First key in \$update must be a \$operator"); throw new \InvalidArgumentException("First key in \$update must be a \$operator");
} }
$batch->update($args[0], $args[1], $options); $bulk->update($args[0], $args[1], $options);
break; break;
case "replaceOne": case "replaceOne":
...@@ -380,17 +380,17 @@ class Collection ...@@ -380,17 +380,17 @@ class Collection
throw new \InvalidArgumentException("First key in \$update must NOT be a \$operator"); throw new \InvalidArgumentException("First key in \$update must NOT be a \$operator");
} }
$batch->update($args[0], $args[1], $options); $bulk->update($args[0], $args[1], $options);
break; break;
case "deleteOne": case "deleteOne":
$options = array_merge($this->getWriteOptions(), isset($args[1]) ? $args[1] : array(), array("limit" => 1)); $options = array_merge($this->getWriteOptions(), isset($args[1]) ? $args[1] : array(), array("limit" => 1));
$batch->delete($args[0], $options); $bulk->delete($args[0], $options);
break; break;
case "deleteMany": case "deleteMany":
$options = array_merge($this->getWriteOptions(), isset($args[1]) ? $args[1] : array(), array("limit" => 0)); $options = array_merge($this->getWriteOptions(), isset($args[1]) ? $args[1] : array(), array("limit" => 0));
$batch->delete($args[0], $options); $bulk->delete($args[0], $options);
break; break;
default: default:
...@@ -398,7 +398,7 @@ class Collection ...@@ -398,7 +398,7 @@ class Collection
} }
} }
} }
return $this->manager->executeWriteBatch($this->ns, $batch, $this->wc); return $this->manager->executeBulkWrite($this->ns, $bulk, $this->wc);
} }
/** /**
...@@ -415,9 +415,9 @@ class Collection ...@@ -415,9 +415,9 @@ class Collection
{ {
$options = array_merge($this->getWriteOptions()); $options = array_merge($this->getWriteOptions());
$batch = new WriteBatch($options["ordered"]); $bulk = new BulkWrite($options["ordered"]);
$id = $batch->insert($document); $id = $bulk->insert($document);
$wr = $this->manager->executeWriteBatch($this->ns, $batch, $this->wc); $wr = $this->manager->executeBulkWrite($this->ns, $bulk, $this->wc);
return new InsertResult($wr, $id); return new InsertResult($wr, $id);
} }
...@@ -430,9 +430,9 @@ class Collection ...@@ -430,9 +430,9 @@ class Collection
{ {
$options = array_merge($this->getWriteOptions(), array("limit" => $limit)); $options = array_merge($this->getWriteOptions(), array("limit" => $limit));
$batch = new WriteBatch($options["ordered"]); $bulk = new BulkWrite($options["ordered"]);
$batch->delete($filter, $options); $bulk->delete($filter, $options);
return $this->manager->executeWriteBatch($this->ns, $batch, $this->wc); return $this->manager->executeBulkWrite($this->ns, $bulk, $this->wc);
} }
/** /**
...@@ -475,9 +475,9 @@ class Collection ...@@ -475,9 +475,9 @@ class Collection
{ {
$options = array_merge($this->getWriteOptions(), $options); $options = array_merge($this->getWriteOptions(), $options);
$batch = new WriteBatch($options["ordered"]); $bulk = new BulkWrite($options["ordered"]);
$batch->update($filter, $update, $options); $bulk->update($filter, $update, $options);
return $this->manager->executeWriteBatch($this->ns, $batch, $this->wc); return $this->manager->executeBulkWrite($this->ns, $bulk, $this->wc);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment