I have tried to use Mongoose to send the list of all users as follows:
server.get(\'/usersList\', function(req, res) {
var users = {};
User.find({},
In case we want to list all documents in Mongoose collection after update or delete
We can edit the function to some thing like this:
exports.product_update = function (req, res, next) {
Product.findByIdAndUpdate(req.params.id, {$set: req.body}, function (err, product) {
if (err) return next(err);
Product.find({}).then(function (products) {
res.send(products);
});
//res.send('Product udpated.');
});
};
This will list all documents on success instead of just showing success message