Creating a database

Let's start by defining the database that we are going to work with. In your shell, execute the following:

> use OrderBase

This will ask MongoDB to switch to a new database, called OrderBase, that we wish to run the commands against. The response will be as follows:

switched to db OrderBase

But wait, how can we switch to a database that does not exist yet? MongoDB flexibility to the rescue! When you tell MongoDB to use a database, it will create that database for you automatically before switching to it.

Get Learning Node.js for Mobile Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.