开发者

mongo group with order

i try to run such code

$collection->group(array('goods_id'=>1, 'server_id'=>1), array('coun开发者_如何学JAVAt' => 0, 'ip'=>'', 'date'=>''), 'function (obj, prev) { prev.count++; prev.ip=obj.user_ip; prev.date=obj.time_download }')->sort(array('count'=>1));

without sort works, with sort not work any ideas?


MongoDB does not yet support grouping and ordering in a single query. Until it can, you can do two things:

  1. Sort the result of the group query in your code ('client side')
  2. Run a MapReduce and run a query, with sort(), on the collection that the MapReduce outputs
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜