Skip to content

DOCS-1241 mongoexport with fields from subdocuments #868

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
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
30 changes: 21 additions & 9 deletions source/reference/mongoexport.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,30 @@ Options

.. option:: --fields <field1[,field2]>, -f <field1[,field2]>

Specify a field or number fields to *include* in the export. All
other fields will be *excluded* from the export. Comma separate a
list of fields to limit the fields exported.
Specify a field or fields to *include* in the export. Use a comma
separated list of fields to specify multiple fields.

For :option:`CSV <mongoexport --csv>` output formats,
:program:`mongoexport` includes only the specified field(s), and the
specified field(s) can be a field within a subdocument.

For :term:`JSON` output formats, :program:`mongoexport` includes
only the specified field(s) **and** the ``_id`` field, and if the
specified field(s) is a field within a subdocument, the
:program:`mongoexport` includes the subdocument with all
its fields, not just the specified field within the document.

.. option:: --fieldFile <file>

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
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``).
As an alternative to :option:`--fields <mongoexport --fields>`, the
:option:`--fieldFile <mongoexport --fields>` option allows you to
specify in a file the field or fields to *include* in the export and
is **only valid** with the :option:`--csv <mongoexport --csv>`
option. The file must have only one field per line, and the line(s)
must end with the LF character (``0x0A``).

:program:`mongoexport` includes only the specified field(s). The
specified field(s) can be a field within a subdocument.

.. option:: --query <JSON>

Expand Down