I have one query regarding real time data update

I am working on MERN stack project. Right now I am getting data from one game and storing that data into Mongodb. also displaying that data onto React page. But i need to display realtime data when player join to game data will be stored in database. to see that data refresh page in React. I need to show player real time data when joins game how can i do that?

Hello @Chirag_Patel ,

Welcome to the community!! :wave:

If I understand the question correctly, you need a way to show realtime data when someone joins the game. Is this correct? When a player joins, where is the data being pushed into? Is it in database?

  • If it is pushing this in Database then you can use changestream.

Change streams allow applications to access real-time data changes without the complexity and risk of tailing the oplog. Applications can use change streams to subscribe to all data changes on a single collection, a database, or an entire deployment, and immediately react to them. Because change streams use the aggregation framework, applications can also filter for specific changes or transform the notifications at will.

To achieve this, you can take a look at Change Streams Tutorial.

  • In case, if this is not being pushed in database then you might need to look for alternate approach maybe from frontend side.

Thanks,
Tarun

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