From the course: Databases for Node.js Developers
Unlock this course with a free trial
Join today to access over 24,400 courses taught by industry experts.
Setting up Mongoose and connecting it to MongoDB - Node.js Tutorial
From the course: Databases for Node.js Developers
Setting up Mongoose and connecting it to MongoDB
- [Instructor] Now that we have covered why we are using Mongoose and how it simplifies working with MongoDB, let's bring it into our project. For that, I have already opened the sample project we set up during the intro. First we need to install Mongoose, so we open the terminal by clicking on Terminal, New Terminal, and there, I simply type npm install mongoose. This installs Mongoose and adds it to our project. It also installs the native MongoDB driver it uses under the hood. To connect our fast for application to MongoDB, we are using a Fastify plugin. A plugin in Fastify is a reusable module that adds functionality to our application. For example, in this case, the mongoose plugin will handle connecting to MongoDB. Our project already contains a scaffold of this plugin, but let's follow the track or the trace to see how this whole plugging loading works. So I open first SRC, and there you have the server.js file. And when you look at that, you see that we are importing a lot of…
Contents
-
-
-
-
-
(Locked)
Managing product data with MongoDB33s
-
Setting up MongoDB with Docker2m 30s
-
(Locked)
Exploring MongoDB with Compass1m 19s
-
(Locked)
Introducing Mongoose2m 59s
-
(Locked)
Setting up Mongoose and connecting it to MongoDB10m 14s
-
(Locked)
Building a model for our products5m 25s
-
(Locked)
Integrating the model into our application3m 55s
-
(Locked)
Populating MongoDB with sample data2m 6s
-
(Locked)
Querying items with Mongoose9m 19s
-
(Locked)
Filtering items by tag4m 27s
-
(Locked)
Item administration: Listing and loading6m 32s
-
(Locked)
Item administration: Create, update, and delete15m 14s
-
(Locked)
Optimizing queries with indexes5m 33s
-
(Locked)
Performing text search in MongoDB5m 34s
-
(Locked)
-
-
-
-