Last active
August 15, 2016 05:38
-
-
Save gscattolin/d962c8ef53aeeea3c995f06ec556b66d to your computer and use it in GitHub Desktop.
MongoDb Most common commands
This file contains 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 characters
db.audit.remove({"reqTime" : { $lt : new Date('01/01/2016').getTime()}}) #remove everything is older than (bad performance) | |
db.audit.find().sort({"createdAt" : -1}).limit(1) #get latest created | |
db.collection.stats() #info about collection | |
export collection mongo in cvs file | |
mongoexport -h host -d dbname -c collectionname --type=csv -f name,side,type,field --out ~/export20160426.csv | |
db.fs.files.aggregate([{$group: {_id: "$contentType", total : { $sum: 1 }}}]) # count type on FS Grid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment