De populate()
methode heeft een optie die filteren toestaat, je kunt dit proberen
Floorplan
.find({
project: req.params.project,
tower: req.params.tower,
isDeleted: false
})
.populate({
path: 'flats',
match: { isDeleted: false }
})
.exec(function(err, floorplan) {
if (err) { return res.send(err); }
if (!floorplan) { return res.status(401).json(); }
res.status(200).json(floorplan);
});
of
Floorplan
.find({
project: req.params.project,
tower: req.params.tower,
isDeleted: false
})
.populate('flats', null, { isDeleted: false })
.exec(function(err, floorplan) {
if (err) { return res.send(err); }
if (!floorplan) { return res.status(401).json(); }
res.status(200).json(floorplan);
});