Connecting to MongoDB
Learn how to establish a MongoDB connection in a Deno application.
We'll cover the following
So far, we’ve implemented an application that lists museums and contains users, allowing them to authenticate. These features are already in place, but they all have a catch: they’re all running against an in-memory database.
We’ve decided to do it this way for the sake of simplicity. However, since most of our implementation doesn’t depend on the delivery mechanism, it shouldn’t change much if the database changes.
In this lesson, we’ll learn how to move one of the application entities to the database. We’ll leverage the abstractions we’ve created in order to do this. The process will be very similar to all the entities, so we’ve decided to learn how to connect to a database just for the users’ module.
To make sure we’re all running against a similar database, we’ll use MongoDB Atlas. Atlas is a product that provides a free MongoDB cluster that we can use to connect our application.
If you’re not familiar with MongoDB, there’s a “one-sentence explanation” from their website. Feel free to go there and learn a little more about it:
“MongoDB is a general purpose, document-based, distributed database built for modern application developers and for the cloud era.”
Get hands-on with 1400+ tech skills courses.