genuinefafa

MongoDB Query - Group & Sort

Sep 30th, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. db.lineaCotizacion.aggregate(
  2.    [
  3.      {
  4.        $group:
  5.          {
  6.            _id: { cliente_id: { cliente: "$cliente.id" } }  ,
  7.            count: { $sum: 1 }
  8.          }
  9.      },
  10.      {
  11.              $sort: { count: -1}
  12.      }
  13.    ]
  14. )
Advertisement
Add Comment
Please, Sign In to add comment