Skip to content

Commit d887e4f

Browse files
committed
Added support for a whereAll query
1 parent b9d99c6 commit d887e4f

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/Jenssegers/Mongodb/Query/Builder.php

+29
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,24 @@ public function orderBy($column, $direction = 'asc')
491491
return $this;
492492
}
493493

494+
/**
495+
* Add a "where all" clause to the query.
496+
*
497+
* @param string $column
498+
* @param array $values
499+
* @param string $boolean
500+
* @param bool $not
501+
* @return $this
502+
*/
503+
public function whereAll($column, array $values, $boolean = 'and', $not = false)
504+
{
505+
$type = 'all';
506+
507+
$this->wheres[] = compact('column', 'type', 'boolean', 'values', 'not');
508+
509+
return $this;
510+
}
511+
494512
/**
495513
* @inheritdoc
496514
*/
@@ -923,6 +941,17 @@ protected function compileWheres()
923941
return $compiled;
924942
}
925943

944+
/**
945+
* @param array $where
946+
* @return array
947+
*/
948+
protected function compileWhereAll(array $where)
949+
{
950+
extract($where);
951+
952+
return [$column => ['$all' => array_values($values)]];
953+
}
954+
926955
/**
927956
* @param array $where
928957
* @return array

0 commit comments

Comments
 (0)