0

我有这个聚合:

$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'
            )
        )
    );

它返回一个数组:

[{type:sourceA, count:2},{type:sourceB, count:6}...]

是否可以让它返回: [sourceA:2, sourceB:6,....] 不循环数组后缀?

4

0 回答 0