Skip to content

API Server

all1124 edited this page Oct 25, 2019 · 2 revisions

API Server

  • router.param(name, callback)
    • Adds callback triggers to route parameters, where name is the name of the parameter and callback is 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
  • 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

Additional Resources

Clone this wiki locally