From the course: Advanced Express
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Adding MongoDB and Mongoose to an Express project
From the course: Advanced Express
Adding MongoDB and Mongoose to an Express project
- [Instructor] With all the credentials in place, we will now make MongoDB available to Express. For that, we will use Mongoose. Mongoose is an object data modeling laboratory for MongoDB. It's very commonly used, lets us create schemas and makes working with Mongoose from NodeJS generally easier. On the flip side it comes with some performance overhead. So if your applications are heavy on database reads and writes and you run into performance issues, Mongoose might be an optimization target. Let's install Mongoose now, for that, I type, npm install --save and my project wrote. And I want to isolate everything that has to do with the database connection in a model on its own. For that I create a new folder in server called, lib. And in lib I create the new file, db.js and here on line one I will, add const mongoose = require('mongoose') And further down I add, module.exports and I want to export a function connect and this function is asynchronous, and takes a database connection…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Setting up a hosted MongoDB server4m 22s
-
(Locked)
Connecting to MongoDB3m 27s
-
(Locked)
Adding MongoDB and Mongoose to an Express project4m 54s
-
(Locked)
Creating a user schema for Mongoose6m 21s
-
(Locked)
Using bcrypt to hash and validate passwords1m 31s
-
(Locked)
Adding password encryption and validation to a Mongoose model5m 12s
-
(Locked)
Creating a user registration route5m 36s
-
(Locked)
Testing the form and reviewing the data in MongoDB1m 33s
-
(Locked)
-
-
-
-