How to get other related column values from MongoDB aggregate group value in PHP?
I can get distinct value by below code in PHP5.6. The database db_x with table/collection table_x, expecting $group columns, there are also some other column is what I need, can I get other columns value?
$res = $db_x->command (
array(
"aggregate" => "table_x",
"pipeline" =>
array(
array( '$group' => array( "_id" => ['id' =>'$code_y', 'name' => '$code_x', 'color' => '$color']))
array( "$replaceRoot" => array( "newRoot" => "$_id" ))
),
"cursor" => ['batchSize' => 200]
)
);