Search⌘ K
AI Features

Creating Databases and Collections

Explore how to create new databases and collections in MongoDB, insert single or multiple documents, and verify collections using commands like use, insertOne, and insertMany. This lesson teaches the foundational steps needed to build and manage data structures in MongoDB for beginners.

A database in MongoDB is a container for collections, and a collection contains a group of documents. Before we can store data, we first need to create these structures.

Creating a database and collection

We don't need a special command to create a database in MongoDB. Simply, switch to a new database name using the use command as follows:

Assembly (GAS x86)
use myNewDatabase

Remember that MongoDB has not created ...