Forrest logo
back to the mongoexport tool

mongoexport:tldr:5178f

mongoexport: Export documents as a JSON array instead of one object per line.
$ mongoexport --collection=${collection_name} --jsonArray
try on your machine

The command "mongoexport" is used to export data from a MongoDB collection into various formats, such as JSON or CSV.

In this specific command, the options are as follows:

--collection=${collection_name}: This specifies the name of the collection from which the data will be exported. The value of ${collection_name} should be replaced with the actual name of the desired collection.

--jsonArray: This option indicates that the exported data should be formatted as a JSON array. By default, each document is stored in a separate JSON object. However, using this option combines all the documents into a single JSON array.

So when you run the command "mongoexport --collection=${collection_name} --jsonArray", it will export the data from the specified collection in a JSON format, with all the documents combined into a JSON array.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the mongoexport tool