MongoDB: Create Document
In one of our previous tutorials, we already have created a collection inside a database. In this tutorial, you will be learning how to delete a particular collection.
In MongoDB, a database is composed of collections, and a collection in composed of documents. A collection can only belong to a single database.
To get on with collection, we first need to start the Mongo Daemon and the Mongo Shell.
If you are using a Mac, open your terminal and start the Mongo Daemon first.
$ mongod
Next, open another new terminal (⌘
+ T
) and start the Mongo Shell.
$ mongo

If you are using Windows, go to the /bin
directory and double-click on the Mongo Daemon mongod.exe
. And in the same /bin
directory, double-click on mongo.exe
next. This is the Mongo Shell from where you will be entering commands.
We first switch to the books
database using the use
command. This is where the collection called comics
was created.
$ use books
To delete the comics
collection, chain the drop() method to it as shown below:
$ db.comics.drop()
The comics
collection is deleted.