Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

$group with $push

db.simple.aggregate( [ { $group: { _id: "$name", total: { $push : "$cnt" } } } ])

{
  "result": [
    {
      "_id": "bar",
      "total": [
        5,
        9
      ]
    },
    {
      "_id": "foo",
      "total": [
        3,
        4,
        5
      ]
    }
  ],
  "ok": 1
}