Skip to content

Instantly share code, notes, and snippets.

@cschlyter
Created June 12, 2013 16:46
Show Gist options
  • Save cschlyter/5767048 to your computer and use it in GitHub Desktop.
Save cschlyter/5767048 to your computer and use it in GitHub Desktop.

Revisions

  1. cschlyter created this gist Jun 12, 2013.
    12 changes: 12 additions & 0 deletions mongo_group_by_day.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    var mention_id = 620996;

    db.mentionStats.aggregate([
    { $match: {'mention_id': mention_id}},
    { $group: {'_id': {
    'year': { '$year': "$verification_date" },
    'month': { '$month': "$verification_date" },
    'day': { '$dayOfMonth': "$verification_date" }
    },
    'retweets': { $last: "$retweets" }}},

    ]).result