An Interest In:
Web News this Week
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
- March 27, 2024
- March 26, 2024
May 19, 2021 02:20 pm GMT
Original Link: https://dev.to/rajeshroyal/how-to-populate-nested-document-in-mongodb-3a91
How to populate nested document in MongoDB.
Recently I run into a situation where I needed to fetch nested mongodb document data and wasted my 1 hour. If you are facing the same this is for you.
Here is the stackoverflow - Populate nested array in mongoose
I used this query -
public courseListRead(): Promise<ICourse[]> { return this.courseModel.find().sort({ index: 1 }).populate('instructor').populate({ path: 'categories', populate: { path: 'posts', model: 'CourseCategoryPost' } }).exec(); }
To populate nested documents you have to use this query.
I'm very beginner at MongoDB.
Thanks.
Original Link: https://dev.to/rajeshroyal/how-to-populate-nested-document-in-mongodb-3a91
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To