April 2020
Intermediate to advanced
716 pages
18h 55m
English
We will be using the mongoose module to implement the user model in this skeleton, as well as all future data models for our MERN applications. Here, we will start by configuring Mongoose and utilizing it to define a connection with the MongoDB database.
First, to install the mongoose module, run the following command:
yarn add mongoose
Then, update the server.js file to import the mongoose module, configure it so that it uses native ES6 promises, and finally use it to handle the connection to the MongoDB database for the project.
mern-skeleton/server/server.js:
import mongoose from 'mongoose'mongoose.Promise = global.Promisemongoose.connect(config.mongoUri, { useNewUrlParser: true, useCreateIndex: ...