Read: Class 09 - 401-advanced-javascript-dania/amman-javascript-401d1 GitHub Wiki

  1. Express: Router Parameters Those are both pretty extreme. Middleware that has to run on 10 out of 15 of your routes (e.g. any route with a city) requires you to either put it on all the routes and make it ignore the requests without a city (ugly) or put that special middleware on every route with a city parameter (also ugly). Express lets you run middleware only when certain parameters are present and expected, eliminating that choice.
  2. Sub Documents in Mongoose Mongoose is a schema driven ORM, which gives us the opportunity to provide structure to our Mongo documents. By default, Mongo (all NoSQL Databases, really) are not structured by default. Mongoose takes some of that pain away from us as developers and allows us to provide some level of rules and validation around our data models.
  3. Joining Data/Documents in Mongo Mongoose is a schema driven ORM, which gives us the opportunity to provide structure to our Mongo documents. By default, Mongo (all NoSQL Databases, really) are not structured by default. Mongoose takes some of that pain away from us as developers and allows us to provide some level of rules and validation around our data models.

4.Direct Population (References) Create a reference column in the collection and then when you save, you need to push() into the reference field with the _id of the referenced document. This results in quicker find() but requires a lot more management on saves, updates, deletes.

5.Virtual Joins In this example, we create a virtual field in teams called players by connecting them with named fields, and then doing a populate as we find/load documents. This โ€œjoinโ€ happens in real time, as the records are being processed by Mongoose and can be quite slow, although convenient.