From cceaab68dd9d104cb17f61c2293ca86cc75358fd Mon Sep 17 00:00:00 2001 From: Steve Renaker Date: Wed, 25 Jan 2017 17:02:52 -0800 Subject: [PATCH] DOCS-9481: shell mkdir should return whether a new directory was created --- source/reference/method/mkdir.txt | 38 ++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/source/reference/method/mkdir.txt b/source/reference/method/mkdir.txt index 6ac419ba610..9d0a959b123 100644 --- a/source/reference/method/mkdir.txt +++ b/source/reference/method/mkdir.txt @@ -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 }