@@ 540-556 (lines=17) @@ | ||
537 | * @return $this |
|
538 | * @throws \BadMethodCallException If the query is not a mapReduce or group command. |
|
539 | */ |
|
540 | public function finalize($finalize) |
|
541 | { |
|
542 | switch ($this->query['type']) { |
|
543 | case Query::TYPE_MAP_REDUCE: |
|
544 | $this->query['mapReduce']['options']['finalize'] = $finalize; |
|
545 | break; |
|
546 | ||
547 | case Query::TYPE_GROUP: |
|
548 | $this->query['group']['options']['finalize'] = $finalize; |
|
549 | break; |
|
550 | ||
551 | default: |
|
552 | throw new \BadMethodCallException('mapReduce(), map() or group() must be called before finalize()'); |
|
553 | } |
|
554 | ||
555 | return $this; |
|
556 | } |
|
557 | ||
558 | /** |
|
559 | * Change the query type to find and optionally set and change the class being queried. |
|
@@ 1373-1389 (lines=17) @@ | ||
1370 | * @return $this |
|
1371 | * @throws \BadMethodCallException If the query is not a mapReduce or group command. |
|
1372 | */ |
|
1373 | public function reduce($reduce) |
|
1374 | { |
|
1375 | switch ($this->query['type']) { |
|
1376 | case Query::TYPE_MAP_REDUCE: |
|
1377 | $this->query['mapReduce']['reduce'] = $reduce; |
|
1378 | break; |
|
1379 | ||
1380 | case Query::TYPE_GROUP: |
|
1381 | $this->query['group']['reduce'] = $reduce; |
|
1382 | break; |
|
1383 | ||
1384 | default: |
|
1385 | throw new \BadMethodCallException('mapReduce(), map() or group() must be called before reduce()'); |
|
1386 | } |
|
1387 | ||
1388 | return $this; |
|
1389 | } |
|
1390 | ||
1391 | /** |
|
1392 | * @param object $document |