Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-646

Bug in aggregation

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.2.3
    • Affects Version/s: None
    • Component/s: None
    • None
    • Environment:
      Mac OS X

      I have this collection
      > db.alunos.find({},

      {armario:1, idade:1}

      )

      {"_id" : ObjectId( "4b7c3d34ca4fb4692dd91c5b") , "idade" : 9 , "armario" : ["Sandwich de presunto","Foto da Popis"]} {"_id" : ObjectId( "4b7c3d19ca4fb4692dd91c59") , "idade" : 8 , "armario" : ["Boneca de pano"]} {"_id" : ObjectId( "4b7c3d2dca4fb4692dd91c5a") , "idade" : 9}

      I try to aggregate like this
      > db.alunos.group({
      key:

      { idade: true }

      ,
      initial:

      { armario: [] }

      ,
      reduce: function(aluno, grupo) {
      if (aluno.armario) {
      aluno.armario.forEach(function(objeto)

      { grupo.armario.push(objeto); }

      )
      }
      },
      finalize: function(out) {}
      })
      [

      {"idade" : 9 , "armario" : ["Sandwich de presunto","Foto da Popis","Boneca de pano"]}

      ,

      {"idade" : 8 , "armario" : ["Sandwich de presunto","Foto da Popis","Boneca de pano"]}

      ]

      Notice that it is aggregating all objects in all keys. That shouldn`t be happening.

            Assignee:
            eliot Eliot Horowitz (Inactive)
            Reporter:
            pedromenezes Pedro Menezes
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: