How to extract real time data without requesting to Mongodb every second

I am building an real time application website that displaying the data from mongodb using Mongoose, I had a backend nodejs system to update the database frequently, and my current approach is to query the database every second, after doing some filtering and calculation, then display to the frontend.

Is there any way to open an websocket or any feature in alias can help me reduce the amount of request while fetching the database frequently like every second, to get the update of the current values in Mongodb?

Many thanks.

If I understand your Use-Case correctly you want to display Updates to Documents within your Database
made by your Node.js backend directly inside your Application.

You could use the changeStream Feature for that. Inside your Application you can listen on multiple Collections for changes and display them accordingly.

See here for more Information:

I hope that helps!


This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.