>mongoexport --type=csv -d school -c students -f _id, name, scores.0.type, scores.0.score -o export.csv
The above command will create a export.csv file with following format:
_id | scores.0.type | scores.0.score | name |
19 | exam | 44.51211102 | Gisela Levin |
20 | exam | 42.174398 | Tressa Schwing |
21 | exam | 46.22894763 | Rosana Vales |
22 | exam | 75.04996548 | Margart Vitello |
In case you want to apply any query filter, then you can use -q option in the command:
>mongoexport --type=csv -d school -c students -f _id, name, scores.0.type, scores.0.score -q {_id:{$gte:19}} -o export.csv
Here I retrieve student data with _id >= 19.