
Ask HN: Best practices to store notifications in Node.js + MongoDB application? - nagarjun
This is somewhat of a complicated subject. Each application has it&#x27;s own needs but I&#x27;m curious to know what best practices and architecture you all recommend when storing a user&#x27;s notifications in a Node.js + MongoDB application.<p>Essentially, we have a notifications icon in our web application (similar to Facebook etc.) that shows notifications based on certain events triggered by other users in the application. Some notifications can also have actions when clicked on them.<p>The plan I had:<p>1. Store all notifications in a &#x27;notifications&#x27; collection<p>2. Each document in the collection has the notification text, unread status and action (if applicable)<p>3. When the user clicks the notification icon in the interface, they see a list of unread notifications and upon closing the drawer, an XHR gets called to mark all notifications as read<p>Is this a good way to do it?
======
davelnewton
I'm not even sure I understand what design issue you're trying to solve. Users
have a list of notifications and they have associated metadata. What else
would you do?

~~~
nagarjun
TBH, I'm not even sure I have an issue that needs solving. I'm trying to
understand how you would design the back-end for a notifications system in a
Node.js application that uses MongoDB.

