So i ve used mongodb watch() and on(change) to detect changes in mongodb database . Now i need to send the changed data to the view ( update variable value after rendering it to the view)
db.collection("shortenedURLs")
.find()
.toArray(function(err, results) {
let change_streams = db.collection("shortenedURLs").watch();
change_streams.on("change", function(change) {
db.collection("shortenedURLs")
.find()
.toArray(function(err, results) {
urls=results // this is the variable
});
});
res.render("./gestion.ejs", { urls: results, user: req.user });
});
});
but nothing happened ! Is there a way to send data to view without render(view , param) ?