Skip to content

Instantly share code, notes, and snippets.

@AyemunHossain
Created April 30, 2023 10:18
Show Gist options
  • Save AyemunHossain/ed0b30af862a7f990a27125af17d9a31 to your computer and use it in GitHub Desktop.
Save AyemunHossain/ed0b30af862a7f990a27125af17d9a31 to your computer and use it in GitHub Desktop.
MongoDB Nested Population, #mongoDB #populate
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