Skip to content

Instantly share code, notes, and snippets.

@sydneyitguy
Last active December 15, 2015 23:39
Show Gist options
  • Save sydneyitguy/5341688 to your computer and use it in GitHub Desktop.
Save sydneyitguy/5341688 to your computer and use it in GitHub Desktop.
mongo queries
db.getMongo().setSlaveOk()
db.currentOp()
db.killOp()
show dbs
show collections
db.events.find({event: 'view', date: { '$gte': 1338472800, '$lt': 1341064800 } }).count()
// Stupid query: Change a field type from string to number
db.COLLECTION_NAME.find({FIELD_NAME: {$type:2}}).limit(1000000).forEach( function(x) {
x.subject = Number(x.subject); db.events.save(x);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment