From the course: Databases for Node.js Developers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Add MongoDB and Mongoose to your project

Add MongoDB and Mongoose to your project

From the course: Databases for Node.js Developers

Start my 1-month free trial

Add MongoDB and Mongoose to your project

- [Instructor] In this video, we will now add Mongoose to our project and we will also set it up to establish the connection to MongoDB. For that I already have opened Visual Studio code and in the terminal, I'm in the shopper directory. So just make sure that you're in the right directory. So I move out again, cd .. and you have to do a cd shopper to really be in the shopper directory. And I'm now running npm install mongoose. And this will add Mongoose to the project and it will also install all sub-dependencies and one sub-dependency of Mongoose is our MongoDB driver that we used in the previous example because under the hood, Mongoose is relying on this driver as well. The next question is, where should we add the code that establishes the connection to MongoDB? And I would argue that the express server should not start at all if we cannot connect to the database, because what's the point if the database is not…

Contents