I am working on a MEAN & Socket.io project where Mongodb in the back-end holds my data and I am using socket.io to publish newly arrived data to all the clients. To make it real time, I am using Mongodb capped collection to send newly arrived data (Insert) to all the clients using socket.io emit. But, I am struggling to find a way to send updated data to a client when existing data gets updated.
I know an alternative way but for that I have to move my data from MongoDB to a flat file and create a watch for that file. But, its not an elegant solution.
If anyone have any better suggestion please share.thanks
Why can't use something like this on the server side whenever there is an update that needs the view to be updated in the frontend
socket.emit('updateData1', {_id: <_id of the data you are updating>, field1: <value>, field2:<value>})
In the front-end(client) just look up the _id and update the object.