I want to use Mongo’s db.collection.group. As far as I understand from 1.0.4 Meteor allow to direct access to the collection and database objects from the npm Mongo driver via new rawCollection.
On `meteor mongo’ shell I can use:
db.orders.group({
  keyf: function(doc) {return {year:doc.createdAt.toISOString().substring(0, 4)}},
  initial: {months:{}},
  reduce: function(order, result) {
    var month = order.createdAt.getMonth()+1,
        date = order.createdAt.getDate();
    month = result.months[month] || (result.months[month] = {});
    date = month[date] || (month[date] = []);
    date.push(order);
  },
  cond: {$and: [{createdAt: {$gt: new Date("2015-02-01")}, createdAt: {$lt: new Date("2015-02-25")}}]}
})
How could I get same effect from my code (server) or meteor shell?
Is this util proper way to get group on collection?
Mongo.Collection.prototype.group = (grouping) ->
  collection = @rawCollection()
  Meteor.wrapAsync(collection.group.bind(collection))(grouping)