mkdir()
Description
mkdir
(path)- Creates a directory at the specified path. This method createsthe entire path specified if the enclosing directory ordirectories do not already exit. The user running the
mongo
shell must have permission to create directories inthe specified path.
This method is equivalent to mkdir -p with BSD or GNU utilities.
The mkdir()
method has the following parameter:
ParameterTypeDescriptionpath
stringA path on the local filesystem.
New in version 3.4.
mkdir()
returns a document withinformation about the result of the operation.
On success, mkdir()
returns the following:
- { "exists" : true, "created" : true }
If the directory at the specified path already exists,mkdir()
returns the following:
- { "exists" : true, "created" : false }
Example
The following command creates a directory called foo
in theshell’s current working directory.
- mkdir("foo")
The above command returns the following output:
- { "exists" : true, "created" : true }