Created
April 30, 2023 10:18
-
-
Save AyemunHossain/ed0b30af862a7f990a27125af17d9a31 to your computer and use it in GitHub Desktop.
MongoDB Nested Population, #mongoDB #populate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Airlines.findById(id) | |
.populate({ | |
path: 'flights', | |
populate:[ | |
{ | |
path: 'planeType', | |
model: 'Plane' | |
}, | |
{ | |
path: 'destination', | |
model: 'Location', | |
populate: { // deeper | |
path: 'state', | |
model: 'State', | |
populate: { // even deeper | |
path: 'region', | |
model: 'Region' | |
}, | |
populate: { // even deepest :) | |
path: 'road', | |
model: 'Road' | |
} | |
} | |
}] | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment