Summary

In this chapter, we have looked at the two methods of creating a Mongoose connection to a MongoDB database, and when you would use each method.

We have learned that the best practice is to create a connection when your application starts and keep it open to be re-used. Tied to this we have seen how and when to close the connection, and how to act upon events emitted by the connection process.

We have also taken a brief look at how to specify different options if you have a more complex database setup, or want to override some defaults.

You should now have connected your MongoosePM project to the MongoosePM database, even though the database doesn't exist yet!

In the next chapter, we're going to start getting stuck into the real meat of Mongoose, ...

Get Mongoose for Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.