diff --git a/source/reference/mongoexport.txt b/source/reference/mongoexport.txt index 1f26e5848a3..e9c514bed03 100644 --- a/source/reference/mongoexport.txt +++ b/source/reference/mongoexport.txt @@ -140,11 +140,12 @@ Options .. option:: --fieldFile - As an alternative to ":option:`--fields `" + As an alternative to :option:`--fields `, the :option:`--fieldFile` option allows you to specify a file - (e.g. `````) to hold a list of field names to specify a list + (e.g. ````) to hold a list of field names to specify a list of fields to *include* in the export. All other fields will be *excluded* from the export. Place one field per line. + Lines must end with the LF character (``0x0A``). .. option:: --query @@ -157,6 +158,10 @@ Options format. By default :program:`mongoexport` writes data using one :term:`JSON` document for every MongoDB document. + If you specify :option:`--csv`, then you must specify either + the :option:`--fieldFile` option or :option:`--fields` option to + describe which fields to export from the collection. + .. option:: --jsonArray Modifies the output of :program:`mongoexport` to write the @@ -211,10 +216,11 @@ collection ``contacts`` from the ``users`` database from the :program:`mongod` instance running on the localhost port number ``27017``. This command writes the export data in :term:`CSV` format into a file located at ``/opt/backups/contacts.csv``. +The :file:`fields.txt` file contains a line-by-line list of fields to export. .. code-block:: sh - mongoexport --db users --collection contacts --csv --out /opt/backups/contacts.csv + mongoexport --db users --collection contacts --csv --fieldFile fields.txt --out /opt/backups/contacts.csv The next example creates an export of the collection ``contacts`` from the MongoDB instance running on the localhost port number ``27017``,