-
Book Overview & Buying
-
Table Of Contents
Nest.js: A Progressive Node.js Framework
By :
While it’s true that MongoDB is not a relational database, it’s also true that it allows “join-like” operations for retrieving two (or more) related documents at once.
Fortunately for us, Mongoose includes a layer of abstraction for these operations and allows us to set up relationships between objects in a clear, concise way. This is provided by using refs in schemas’ properties, as well as the .populate() method (that triggers something known as the “population” process; more on it later.)
Let’s go back to our blog example. Remember that so far we only had a schema that defined our blog entries. We will create a second schema that will allow us to create comments for each blog entry, and save them to the database in a way that allows us later to retrieve both a blog entry as well as the comments that belong to it, all in a single database operation.
So, first, we create a CommentSchema like...
Change the font size
Change margin width
Change background colour