Below is my code, its does pull some fields from DB but not all, I am stuck on this for almost 2 days now, kindly help me fix this bug.
I need to pull data from mongo DB and I am failing to pull all the fields
router.get('/areas', (req, res) => {
area
.find()
.exec()
.then((foundarea) => {
console.log(foundarea[0].name);
res.render('areas/areas.ejs', { areas: foundarea });
})
.catch((err) => {
if (err) {
console.log(err);
} else {
console.log(foundarea);
}
});
});
You can try this:
area.find().select({"name":1, "column2":1})
.exec()
just put name of the column and :1 to include it in the result.