Reputation: 51
I try to group documents by two fields, 'a' and 'b', to get all distinct pairs of them in the collection. It works in Compass, but not in PHP 7.2. Here my code:
$pipeline = [
['$group' =>
['_id' =>
['a' => '$a',
'b' => '$b']
]
]
];
$collection->aggregate($pipeline);
What i get is:
Array ( [_id] => Array ( [a] => 1 ) )
Array ( [_id] => Array ( [a] => 2 ) )
Array ( [_id] => Array ( [a] => 3 ) )
Array ( [_id] => Array ( [a] => 4 ) )
Array ( [_id] => Array ( [a] => 5 ) )
Field 'b' is missing.
Upvotes: 0
Views: 283