
The MongoDB Database Tools are a suite of command-line utilities for working with MongoDB. Mongoexport is part of the MongoDB Database Tools package. The following example code exports the results of a query to a CSV file: mongoexport -db=PetHotel -collection=pets -type=csv -fields=_id,name,type,weight -query='' -out=data/dogs.csv Check for mongoexport

a new Terminal or Command Prompt window).ĭon’t run mongoexport commands from the mongo shell. You need to run mongoexport commands from your system’s command line (e.g. The syntax for mongoexport goes like this: mongoexport -collection= This article shows you how to use mongoexport to export MongoDB query results to a CSV file.

One of the things you can do with this utitlity is export query results. The MongoDB Database Tools include a utility called mongoexport that enables you to export MongoDB data to a CSV or JSON file.
