Skip to content

Commit

Permalink
QueryBuilder::update() implemented custom pipelines.
Browse files Browse the repository at this point in the history
  • Loading branch information
TCB13 committed Jul 17, 2019
1 parent 86ec665 commit 5f82dda
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,12 @@ public function update($update): UpdateResult
throw new Exception("You must set a filter (where query) to update records.");
}

$pipeline = [];
// Build the pipeline
if (is_object($this->customPipeline) && !empty($this->customPipeline->pipeline) && $this->customPipeline->beforeQb) {
$pipeline = $this->customPipeline->pipeline;
} else {
$pipeline = [];
}

if (is_array($update)) {
$inc = [];
Expand Down Expand Up @@ -562,6 +567,10 @@ public function update($update): UpdateResult
}
}

if (is_object($this->customPipeline) && !empty($this->customPipeline->pipeline) && !$this->customPipeline->beforeQb) {
$pipeline = array_merge($pipeline, $this->customPipeline->pipeline);
}

// Run the update query
return $this->collection->updateMany($this->getNormalizedFilters(), $pipeline);
}
Expand Down

0 comments on commit 5f82dda

Please sign in to comment.