@@ 143-157 (lines=15) @@ | ||
140 | * @return \Sokil\Mongo\Operator |
|
141 | * @throws \Sokil\Mongo\Exception |
|
142 | */ |
|
143 | public function pushEachSort($field, array $sort) |
|
144 | { |
|
145 | // add modifiers |
|
146 | if(!$sort) { |
|
147 | throw new Exception('Sort condition is empty'); |
|
148 | } |
|
149 | ||
150 | if(!isset($this->_operators['$push'][$field]['$each'])) { |
|
151 | throw new Exception('Field ' . $field . ' must be pushed with $each modifier'); |
|
152 | } |
|
153 | ||
154 | $this->_operators['$push'][$field]['$sort'] = $sort; |
|
155 | ||
156 | return $this; |
|
157 | } |
|
158 | ||
159 | /** |
|
160 | * The $position modifier specifies the location in the array at which |
|
@@ 171-187 (lines=17) @@ | ||
168 | * @return \Sokil\Mongo\Operator |
|
169 | * @throws \Sokil\Mongo\Exception |
|
170 | */ |
|
171 | public function pushEachPosition($field, $position) |
|
172 | { |
|
173 | $position = (int) $position; |
|
174 | ||
175 | // add modifiers |
|
176 | if($position <= 0) { |
|
177 | throw new Exception('Position must be greater 0'); |
|
178 | } |
|
179 | ||
180 | if(!isset($this->_operators['$push'][$field]['$each'])) { |
|
181 | throw new Exception('Field ' . $field . ' must be pushed with $each modifier'); |
|
182 | } |
|
183 | ||
184 | $this->_operators['$push'][$field]['$position'] = $position; |
|
185 | ||
186 | return $this; |
|
187 | } |
|
188 | ||
189 | public function addToSet($field, $value) |
|
190 | { |