In this chapter, we will cover the range of data relationships available within MongoDB and Mongoose. This will include inner-model relationships, such as validations, virtual properties, and pre-save hooks. We will also cover document relationships, such as embedding sub-documents and using object references to model parent and child relationships.
In this chapter, we will cover the following recipes :
- Working with data validations and virtuals in Mongoose
- Creating sub-documents in Mongoose models
- Using pre-save hooks and custom methods in Mongoose models
- Creating embedded documents in MongoDB with objectId
- Creating relational documents in MongoDB with population