Created
April 10, 2014 05:06
-
-
Save keepcosmos/10344110 to your computer and use it in GitHub Desktop.
Revisions
-
keepcosmos created this gist
Apr 10, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ db.messenger_rooms.group({ keyf: function(doc){ var date = new Date(doc.created_at); date.setHours(date.getHours() + 9); var dateKey = (date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate()); return {'day':dateKey}; }, cond: {created_at: {$gte: ISODate("2014-04-01"), $lte: ISODate("2014-04-03")}}, initial: { count: 0, reserved_count: 0}, reduce: function(doc, aggregator){ aggregator.count += 1; if(doc.reservation_status !== undefined && doc.reservation_status !== null) aggregator.reserved_count++; } });