Skip to content

DOCS-7241: adds get_id and delete_id to mongofiles ref #2590

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
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
36 changes: 33 additions & 3 deletions source/reference/program/mongofiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,34 @@ Commands
system.

Here, ``<filename>`` refers to the name the object will have in
GridFS, and :program:`mongofiles` assumes that this reflects the name the
file has on the local file system. If the local filename is
different use the :option:`mongofiles --local` option.
GridFS. :program:`mongofiles` writes the file to the local
file system using the file's ``filename`` in GridFS. To choose a
different location for the file on the local file system, use the
:option:`--local` option.

.. describe:: get_id "<ObjectId>"

.. versionadded:: 3.2.0

Copy the specified file from GridFS storage to the local file system.

Here ``<ObjectId>`` refers to the extended JSON ``_id`` of the
object in GridFS. :program:`mongofiles` writes the file to the local
file system using the file's ``filename`` in GridFS. To choose a
different location for the file on the local file system, use the
:option:`--local` option.

.. describe:: delete <filename>

Delete the specified file from GridFS storage.

.. describe:: delete_id "<ObjectId>"

.. versionadded:: 3.2.0

Delete the specified file from GridFS storage. Specify the file using
its ``_id``.

Examples
--------

Expand Down Expand Up @@ -229,3 +249,13 @@ database named ``32-corinth.lp``, you can use the following command:
.. code-block:: sh

mongofiles -d records get 32-corinth.lp

To fetch the file from the GridFS collection in the ``records`` database
with ``_id: ObjectId("56feac751f417d0357e7140f")``, you can use
the following command:

.. code-block:: sh

mongofiles -d records get_id 'ObjectId("56feac751f417d0357e7140f")'

You must include quotation marks around the ``_id``.