mongoose make collections and populate them code example
Example 1: mongoose create populate response
let user = await User.create({ ... })
user = await user.populate('company').execPopulate()
Example 2: mongodb mongoose document populate nested document
Project.find(query)
.populate({
path: 'pages',
populate: [{
path: 'components',
model: 'Component'
},{
path: 'AnotherRef',
model: 'AnotherRef',
select: 'firstname lastname'
}]
})
.exec(function(err, docs) {});