MongoDB – Create Collection:

In mongoDB, Collection is nothing but a container of all documents.It is almost equivalent to table in RDBMS which is a combination of rows and columns. We can Create collections by using the below syntax.

Parameter Type Description
Name string Name of the collection
Options document Optional. Configuration options for creating a capped collection, for pre-allocating space in a new collection, or for creating a view.

Use the test database and verify the database in which you are in.

Create collection called “i2tutorial” by using below command

Check the collection which you created.

Also, you can create collections automatically by inserting a document into it.

Insert the data into the collection called ” imongo”

Check if the collection imongo and the data inserted exists or not.