Shell function to wrap mongoexport
As simple as it seems to export a MongoDB collection, I can never seem to remember the parameters. Here is a small function that I dropped in my .bashrc file.
emongo(){ if [ "$#" -ne 2 ]; then echo 'Needs 2 parameters' echo 'mongoexport --db ${1} --collection ${2} --out ${2}' return 1 fi mongoexport --db ${1} --collection ${2} --out ${2}.json }
Completely unnecessary but I’m just that lazy.