How to make this MongoDB aggregation return key:value? -


i have aggregation:

$out = $db->stats->aggregate (         array('$match' => $where),         ,array( '$group' =>              array( "_id" => '$traffic.source',                      'count'=> array('$sum' => 1)             )         )         ,array( '$project' =>              array( "_id" => 0,                  'type' => '$_id',                 'count' => '$count'             )         )     ); 

which returns array with:

[{type:sourcea, count:2},{type:sourceb, count:6}...] 

is possible make return: [sourcea:2, sourceb:6,....] without looping array afterwords?


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -