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.

  if [ "$#" -ne 2 ]; then
    echo 'Needs 2 parameters'
    echo 'mongoexport --db ${1} --collection ${2} --out ${2}'
    return 1
  mongoexport --db ${1} --collection ${2} --out ${2}.json

Completely unnecessary but I’m just that lazy.

Leave a Reply

Your email address will not be published. Required fields are marked *