I'm making a Node.Js with MongoDB application and I need to refresh one of my HBS pages every time something changes on my MongoDB collection.
Don't know exactly what I should do. What is the best approach to do so?
Cheers.
Thank you for all your help. The best (and easiest) solution that I've found was using websockets with Socket.io. I've used the following logic:
socket.emit('UpdateOnDatabase');
io.on('connection', function(socket){
socket.on('UpdateOnDatabase', function(msg){
socket.broadcast.emit('RefreshPage');
});
});
var socket = io.connect('http://localhost:3000');
socket.on('RefreshPage', function (data) {
location.reload();
});
I've changed my way of thinking a bit but it's working exactly as I want.
Cheers.