View profile

Introducing Mastering Mongoose, Our New eBook

Mongoose is the most popular Node.js database framework: over 1 million GitHub repos use Mongoose. Mo
Introducing Mastering Mongoose, Our New eBook
By Mastering JS Weekly • Issue #33 • View online
Mongoose is the most popular Node.js database framework: over 1 million GitHub repos use Mongoose. Mongoose is also a key part of Mastering JS’ recommended JavaScript stack. That’s why, for our first eBook, we’ve released a guide to building fast, production-ready APIs and backend services with Node.js and MongoDB using Mongoose.

The complete guide to building fast, production-ready Mongoose apps
The complete guide to building fast, production-ready Mongoose apps
Documentation vs eBooks
The role of books in tech has changed drastically over the last 20 years. Because online documentation has become so sophisticated, books are no longer used as references. Very few developers still keep a copy of Effective C++ or CLRS on their desk to refer to, most just Google for the information they’re looking for rather than thumbing through a book.
Mastering Mongoose is not meant to be a reference or a replacement for Mongoose documentation. It’s meant to be a guide that walks you through Mongoose fundamentals, and explains how those fundamentals apply when building apps.
There are countless different Mongoose apps out there, built at different times with different constraints. The Mongoose documentation needs to help developers working on these apps be productive and solve problems. On the other hand, Mastering Mongoose intentionally omits numerous bits of functionality that aren’t relevant to building apps.
Instead of enumerating all of Mongoose’s functionality, Mastering Mongoose focuses on helping you master the principles that are fundamental to building virtually any Mongoose app.

Principle of Data Locality
Mastering Mongoose’s chapter about schema design describes 3 principles for designing Mongoose schemas that scale to over 100k documents:
  1. The Principle of Least Cardinality
  2. The Principle of Denormalization
  3. The Principle of Data Locality
The Principle of Data Locality states that a document should store all the data you need to display a detail page for that document. A concrete example is a blog post. I don’t think it is any surprise that NoSQL databases became popular shortly after the rise of blogging: loading the data to display a blog post in SQL quickly devolves into JOIN hell because you need to join together comments, tags, authors, etc.
Instead, the Principle of Data Locality encourages you to store all relevant data in a single blog post document: authors, tags, comments, even related posts. There are several reasons for this. First is performance: most blog post documents will be loaded thousands of times for every time they’re modified. Ensuring all the data is in one place helps you reduce load on your database and minimize the number of queries you need.
Another reason is maintenance and debugging. Because the data in the database lines up so closely with what ends up on the user’s screen, it is easy to tweak the database to fix issues. Bugs happen, but their impact on users can be minimized if you can easily tweak the state of their data.
Get Mastering Mongoose Today
As a Mastering JS subscriber, you can buy a discounted copy of Mastering Mongoose here. If leave a review on GoodReads after purchasing, we will give you an extra $5 back. Thanks for your continued support!
Most Recent Tutorials
Did you enjoy this issue?
Mastering JS Weekly

A weekly summary of our tutorials

If you don't want these updates anymore, please unsubscribe here.
If you were forwarded this newsletter and you like it, you can subscribe here.
Powered by Revue