Read 9 API Server - 401-advanced-javascript-hanna-alemu/seattle-javascript-401d31 GitHub Wiki

Populate Virtuals

Arrays that grow without bound are a MongoDB anti-pattern. Using mongoose virtuals, you can define more sophisticated relationships between documents.

You can provide multiple callbacks, and all are treated equally, and behave just like middleware, except that these callbacks may invoke next('route') to bypass the remaining route callback(s). You can use this mechanism to perform pre-conditions on a route then pass control to subsequent routes when there is no reason to proceed with the route matched.

router.param(name, callback)

Adds callback triggers to route parameters, where name is the name of the parameter and callback is the callback function.