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

mod rewrite - Using "?" when rewriting the URL -

.htaccess: Transfer name to index.php if not directory public -

Admob integration with pygame in android -