-
npm init
-- to track the dependencies. - Install mongoose
npm install mongoose --save
- Connecting to database: Mongoose do not automatically knows about database. we've to tell it explicitly.
//connection.js
const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/testaroo');
mongoose.connection.once('open', function(){
console.log('Connection is made');
}).on('error', function(error){
console.log('Connection error', error);
})
Top comments (0)