Skip to content

Commit

Permalink
fixed aggregate
Browse files Browse the repository at this point in the history
  • Loading branch information
lhs168 committed Feb 7, 2018
1 parent bc5c28c commit 0bc8adb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Fasim/Db/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ protected function aggregate($type, $field) {
$group = [];
$isGroup = $this->data['group'] !== '';
if (!empty($this->data['where'])) {
$pipeline['$match'] = $this->data['where'];
$pipeline[] = ['$match' => $this->data['where']];
}
$group = [
'_id' => $isGroup ? '$'.$this->data['group'] : '1',
'result' => [ '$'.$type => '$'.$field ]
];
$pipeline['$group'] = $group;
$results = $db->aggregate($this->data['table'], [ $pipeline ]);
$pipeline[] = ['$group' => $group];
$results = $db->aggregate($this->data['table'], $pipeline);
if ($isGroup) {
if (empty($results) || empty($results[0]->result)) {
return [];
Expand Down

0 comments on commit 0bc8adb

Please sign in to comment.