Adding facebook like notification feature to MERN app with isRead flag

Viewed 85

I am trying to add facebook like notification feature for my app. Instead of different notification for different user I have general notifications which are common to all the users. And for every user I want to have isRead flag so that I can show the user read and unread notifications. So, the question is, how should I design my model and how should I achieve the isRead functionality??

One idea in my mind is to create a notification collection with all the notification and have a field of readBy in which I will store the userId of all the users who have read this notification. And while showing the notifications to the user I can check whether his name is in the readBy field or not and show read or unread notification accordingly.

But is this method efficient? If not please suggest any more efficient method.

0 Answers
Related