Connecting to a MongoDB server using Mongoose

Below is a sample code for connecting to a MongoDB server using Mongoose, a popular Node.js MongoDB ODM module:

mongoose.connect('mongodb://localhost/app');
mongoose.connection.on('open', function() {
console.log("Connected to Mongoose...");
});

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.