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
38 changes: 37 additions & 1 deletion source/reference/method/mkdir.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,46 @@ Description

Creates a directory at the specified path. This method creates
the entire path specified if the enclosing directory or
directories do not already exit.
directories do not already exit. The user running the
:program:`mongo` shell must have permission to create directories in
the specified path.

This method is equivalent to :command:`mkdir -p` with BSD or GNU utilities.

The :method:`mkdir()` method has the following parameter:

.. include:: /includes/apiargs/method-mkdir-param.rst

.. versionadded:: 3.4

:method:`mkdir()` returns a document with
information about the result of the operation.

On success, :method:`mkdir()` returns the following:

.. code-block:: javascript

{ "exists" : true, "created" : true }

If the directory at the specified path already exists,
:method:`mkdir()` returns the following:

.. code-block:: javascript

{ "exists" : true, "created" : false }

Example
-------

The following command creates a directory called ``foo`` in the
shell's current working directory.

.. code-block:: javascript

mkdir("foo")

The above command returns the following output:

.. code-block:: javascript

{ "exists" : true, "created" : true }