This course will be retired on August 10, 2021. We recommend "REST APIs with Express" for up-to-date content.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
As long as we're doing common CRUD operations with our data, we most likely won't need to extend mongoose beyond what it does out-of-the-box. But real world applications will almost always have some atypical behavior they will need to implement, and ours is no exception.
Resources:
Blog series about Modelling one-to-many (AKA parent-child) relationships in MongoDB:
6 Rules of Thumb for MongoDB Schema Design, By William Zola, Lead Technical Support Engineer at MongoDB:
Part 1
Part 2
Part 3
MongoDB documentation on data modelling
MDN page detailing Array.prototype.sort
JavaScript Patterns, by Stoyan Stefanov, is a great book on writing solid JavaScript code. On page 134, Stoyan Stafanov shows how to write a recursive deep-extend function.
Also, studying source code is a great way to learn! Here's jQuery's implementation of $.extend.
Skip down to line 124 (the line may move, so you can also use the browser's find in page and type in 'extend' to see where it is defined (jQuery.extend = …)
.
You need to sign up for Treehouse in order to download course files.
Sign up