O'Reilly logo

Hands-On Full Stack Web Development with Aurelia by Erikson Haziz Murrugarra Sifuentes, Diego Jose Arguelles Rojas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Configuring Mongoose

This is where the best part starts. So, we will need to create a connection to the database; to do this, open the mongoose-connection.js file and apply the following changes:

const mongoose = require('mongoose')mongoose.connect('mongodb://localhost:32768/wcDb')mongoose.Promise = global.Promisemongoose.connection.on('connected', () => {  console.log('connection is ready')})mongoose.connection.on('error', () => {  console.log(err)})

First, we import the Mongoose module and host it into the mongoose constant. Then, we call the connect function and pass the connection URL using the host and port that points to our MongoDB docker container. Lastly, we tell mongoose that our database name will be wcDb. If the connection was successful, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required