Grouping documents from collection by data or something else

Hello,

I’m trying to implement a group by query using agregate.
Here is the query :

db['cfs.medias.filerecord'].aggregate(
   [
      {
       $project:
         {
           year: { $year: "$uploadedAt" },
           month: { $month: "$uploadedAt" },
           day: { $dayOfMonth: "$uploadedAt" },
           hour: { $hour: "$uploadedAt" },
           minutes: { $minute: "$uploadedAt" },
           seconds: { $second: "$uploadedAt" },
           milliseconds: { $millisecond: "$uploadedAt" },
           dayOfYear: { $dayOfYear: "$uploadedAt" },
           dayOfWeek: { $dayOfWeek: "$uploadedAt" },
           week: { $week: "$uploadedAt" }
         }
     },
     { "$group" : 
         { "_id" : { 
                "year" : "$year", 
                "month" : "$month",
                "day" : "$day"
             }, 
          "medias": { 
                "$push":  {id:"$_id"}
                } 
          }
      }
   ]
);

I’d like to push the current document inside the medias Array instead of its id. How would one do that with mongo 2.4? As far as I know meteor does not support mongo 3. nore 2.6 ?

Thanks a lot !

Gabriel

Why we need to worry about 2.6 vs 2.4 here?
If you looking to aggregate, try this package: https://github.com/meteorhacks/meteor-aggregate/

Anyway with the next meteor release we’ll have official 2.6 support. (May be 3.0 as well)

Thanks Arunoda ! Well, the $$ROOT seems not to be valid. Here I need to put the in the media the current document and $$ROOT looks like accessible only on 3.0.

Am I wrong here ?

Well, I know why I’m not using aggreggate package. I can’t use it on FS collection. Any idea what would be the best way ?