From the course: MERN Essential Training (2020)

Unlock the full course today

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

Set up your database

Set up your database

From the course: MERN Essential Training (2020)

Start my 1-month free trial

Set up your database

- [Instructor] We are now ready to set up our database inside of our APIs, so let's get to it. So I'm going to close all the other files that we created and open up index.js inside of the backend folder and then here what we're going to do is start, initializing the database inside of that particular file. So what I'm going to do first is import a few things, so for example we're going to import, mongoose first, from mongoose and then import bodyparser, from body parser. Good. And then what we need to do is create the mongoose connection to the mongo database that we, initialized earlier. So let's go ahead and do that. So I'm going to put a note here, so this is the, mongo connection and we're going to use mongoose for that. Again mongoose is a library that allows us to simplify the connections to mongo and also use shorter syntax for queries. So I'm going to use a promise for that and use the global…

Contents