Skip to content

Commit 878189c

Browse files
author
TCB13
committed
Add unwind(string $path, ?string $includeArrayIndex = null, bool $preserveNullAndEmptyArrays = false).
1 parent a6527a8 commit 878189c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/QueryBuilder.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,24 @@ public function join($collection, $localField, $operatorOrForeignField, $foreign
385385
return $this;
386386
}
387387

388+
public function unwind(string $path, ?string $includeArrayIndex = null, bool $preserveNullAndEmptyArrays = false): self
389+
{
390+
$unwind = [
391+
"path" => "\$" . $path,
392+
"preserveNullAndEmptyArrays" => $preserveNullAndEmptyArrays,
393+
];
394+
395+
if ($includeArrayIndex !== null) {
396+
$unwind["includeArrayIndex"] = $includeArrayIndex;
397+
}
398+
399+
$this->unwind = [
400+
"\$unwind" => $unwind
401+
];
402+
403+
return $this;
404+
}
405+
388406
/*
389407
* Sorting Methods
390408
*/

0 commit comments

Comments
 (0)