-
Notifications
You must be signed in to change notification settings - Fork 7
API Server
all1124 edited this page Oct 25, 2019
·
2 revisions
- router.param(name, callback)
- Adds callback triggers to route parameters, where
nameis the name of the parameter andcallbackis the callback function - The parameters of the callback function are:
- req, the request object
- res, the response object
- next, indicating the next middleware function
- The value of the name parameter
- The name of the parameter
- Adds callback triggers to route parameters, where
- Mongoose has 4 types of middleware:
- document middleware
- Document middleware functions, this refers to the document
- validate
- save
- remove
- updateOne
- deleteOne
- init (note: init hooks are synchronous)
- model middleware
- aggregate middleware
- Aggregate middleware is for MyModel.aggregate()
- query middleware
- Query middleware functions, this refers to the query
- count
- deleteMany
- deleteOne
- find
- findOne
- findOneAndDelete
- findOneAndRemove
- findOneAndUpdate
- remove
- update
- updateOne
- updateMany
- document middleware