How it works...
By limiting population to our load and read method, we guarantee we will only invoke population when we make requests for a specific user. This is important, because population can be a source of performance loss if our database performs population too often. Much like an SQL query with too many JOIN operations, having too many populate operations can slow down your query time significantly. By limiting our populate query to only when we are fetching a single user record, we are providing some built-in limits to the scope of how many documents will be populated in any given request.
The populate method is a very powerful tool for composing different documents together in MongoDB, and provides the closest option to how a relational ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access