I'm planning out a web application now that will notify the user in the app based on certain events. While I would like to eventually extend this to mobile push notifications and email notifications, my initial implementation is only concerned with generating notifications in the app (think of Facebook or Instagram notifications, where you only see the red dot when there are new notifications and you can view a list of the notifications in-app).
I searched around for design patterns for this but all the info I found was how to create browser push notifications (which are awful and I don't want to do them).
My initial idea would be to create a Mongoose schema for a Notification, possibly something like
{
name: String,
notifType: String,
timestamp: {type: Date, default: Date.now()},
unread: {type: Boolean, default: true}
}
and then when a Notification instance is triggered, push it into an array of ObjectId refs on the User record.
Am I on the right track or are there better ways? It seems like this should be a common design pattern.