I'm designing a real-estate website and I was wondering can I link my front-end webpage that shows the available properties for sale that a new property icon is added when I add to my MongoDB ? to elaborate more, I have a template for each single property which includes picture and some other info about the property, what i want to do is when i add a new collection to my database to appear on my webpage with this template. Thanks in advance
how to get my front-end updated when I add to my database?
932 Views Asked by ninja111 At
3
There are 3 best solutions below
0

If you want to use angular for retrieving and showing data.
You can refer to these sites : This one tells how to populate data in angular. & To get a crisp of doing it with mongo db
0

What you actually need is server side event system updating your frontend, Changestream
that @user1108069 mentioned can be useful in detecting new changes or you can literally identify that when a request is being made to add a new property.
The task here is to update the frontend's current connections to update their view to get the new (load) changes, you can do this in multiple ways.
- Use something like firebase realtime DB on the side Firebase Realtime DB
- Use any other server side events broker for you This should work too
- You can create your own full duplex system, using something like socket.io but do remember that concurrent connections needs to be handled properly. You cannot keep them connected to your server all the time.
Cheers!
MongoDB can be watched, since your question has 'node.js' tag so assume you use node.js in the server side, I check the doc and there's a
watch
API returning aChangeStream
object which you may use, just for your reference