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
Post a Comment