Mongoose allows new methods to be added to the Models and Documents in the application. Scott explains how these new methods will allow a middleware API to be built around the authentication process by using lifecycle events like before save and before validation.
- So there are so many ways to do this password process…with Express and Mongo.…So many ways, I don't think there is a right way.…You can make a middleware.…Globally you can put one on the route,…you can put one on the router.…You can just have a utility function…that you require to use everywhere.…There's so many ways you can do this one thing.…But Mongoose allows us to teach our Models…and our Documents new tricks…by adding custom functions to them.…And this is where we're going to do it.…Because it makes sense to do it, to me at least,…on the actual models…because those are the things…that are going to save the password.…
So instead of having Express or Node know…about passing passwords,…I should just tell all my models about it,…like, hey, you know how to hash a password.…Hash yourself.…Or check yourself.…Versus like Node, check this password on this model.…All right it's like, just check yourself…and tell me if you're right.…So to teach Mongoose about new tricks,…there's a couple of ways we can do it.…So when we have our schema object that we create…
This course was created by Frontend Masters. It was originally released on 12/30/2015. We're pleased to host this training in our library.
- Executing Node.js
- Using Express
- What is middleware?
- Testing in Node.js
- Using Mongo with Node.js
- Data modeling
- Querying data with Mongoose
- Identifying sensitive routes
- Configuring the deployment
Skill Level Intermediate
Building a Slack Bot with Node.js Microserviceswith Daniel Khan2h 9m Intermediate
Building APIs Using Hapi in Node.jswith Kirsten Hunter2h 23m Intermediate
2. REST APIs
5. Organization and Configuration
7. Data Modeling
10. Securing Routes
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.