Search code examples
mongodbcsvmongoexport

mongoexport only object value


I have a really simple mongodb with only one property that i am saving, email. I am successful at exporting that collection into a csv. This is what it looks like.

https://i.sstatic.net/qn9Vp.jpg

What i would love to be able to do is only export that data this is in the 'email' property. That way I do not have to do cleanup everything i want to use this .csv in mailchimp etc...

This is my mongoexport command

mongoexport -d myDatabase -c emails -o export.csv

Am i able to do this in mongoexport or do i need to do some custom view?

Thanks


Solution

  • You should mongoexport in following way:

    mongoexport -d myDatabase -c emails -f email --csv -o export.csv
    

    where email is name of field that you want to export.

    You need to give full path while exporting.