Skip to content

Commit 5f82dda

Browse files
committed
QueryBuilder::update() implemented custom pipelines.
1 parent 86ec665 commit 5f82dda

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/QueryBuilder.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,12 @@ public function update($update): UpdateResult
509509
throw new Exception("You must set a filter (where query) to update records.");
510510
}
511511

512-
$pipeline = [];
512+
// Build the pipeline
513+
if (is_object($this->customPipeline) && !empty($this->customPipeline->pipeline) && $this->customPipeline->beforeQb) {
514+
$pipeline = $this->customPipeline->pipeline;
515+
} else {
516+
$pipeline = [];
517+
}
513518

514519
if (is_array($update)) {
515520
$inc = [];
@@ -562,6 +567,10 @@ public function update($update): UpdateResult
562567
}
563568
}
564569

570+
if (is_object($this->customPipeline) && !empty($this->customPipeline->pipeline) && !$this->customPipeline->beforeQb) {
571+
$pipeline = array_merge($pipeline, $this->customPipeline->pipeline);
572+
}
573+
565574
// Run the update query
566575
return $this->collection->updateMany($this->getNormalizedFilters(), $pipeline);
567576
}

0 commit comments

Comments
 (0)