Skip to content

Instantly share code, notes, and snippets.

@guenodz
Last active July 26, 2017 20:53
Show Gist options
  • Save guenodz/998d18238b9bc6217713cfc84f2619bd to your computer and use it in GitHub Desktop.
Save guenodz/998d18238b9bc6217713cfc84f2619bd to your computer and use it in GitHub Desktop.
// Find the total number of posts
db.getCollection('COLLECTION_NAME').find({}).count()
// Find posts published before a particular date (Ex: before April 4th, 2016)
db.getCollection('COLLECTION_NAME').find({"created_time" : {$lt: ISODate("2016-04-04T00:00:00.000Z")} })
// Find posts published after a particular date (Ex: after April 4th, 2016)
db.getCollection('COLLECTION_NAME').find({"created_time" : {$gt: ISODate("2016-04-04T00:00:00.000Z")} })
// Find posts published between two particular dates sorted in an ascending order (Ex: between April 4th, 2016 and May 4th, 2016)
db.getCollection('COLLECTION_NAME').find({"created_time" : {$gt: ISODate("2016-04-04T00:00:00.000Z"), $lt: ISODate("2016-05-05T00:00:00.000Z")} }).sort({"created_time": 1})
// Find posts published by a particular member
db.getCollection('COLLECTION_NAME').find({"from.name" : "FULL_NAME"}).sort({"created_time": 1})
// Find posts by type (Ex: status posts. You can search by any other type in: ["video", "link", "photo", "event", "note", "album"] )
db.getCollection('COLLECTION_NAME').find({"type" : "status"})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment