I'm using Node.js and Mongoose to access a MongoDB database and return an array of objects from a MongoDB collection. However, I want to append a property to each of the returned objects. My code is shown below
router.get('/admin/manage_accounts/view_all', (req,res) => {
Community_Member.find({}, (error, community_member) => {
community_member.forEach(function(element){
element.Role = "Community Member"
})
console.log(community_member)
res.send(community_member)
})
}
The objects from the database are returned, but the Role property is not appended to any of the objects and I'm not certain why. Can anyone give me a bit of insight?
element["Role"] = "Community Member"?