Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions source/reference/mongoexport.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,12 @@ Options

.. option:: --fieldFile <file>

As an alternative to ":option:`--fields <mongoexport --fields>`"
As an alternative to :option:`--fields <mongoexport --fields>`,
the :option:`--fieldFile` option allows you to specify a file
(e.g. ``<file>```) to hold a list of field names to specify a list
(e.g. ``<file>``) 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 <JSON>

Expand All @@ -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
Expand Down Expand Up @@ -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``,
Expand Down