Is this an efficient way of storing notifications with MongoDB. I want to keep track of past notifications and if the notification has been read by the user.
NotificationSchema: {
title: {type: String, required: true},
context: {type: String, required: true},
createdAt: {type: Date, default: Date.now(), required: true},
readBy: [
userObjectID: {type: mongoose.Schema.Types.ObjectId, required: true},
readAt: {type: Date, required: true, default: Date.now()}
]
}
My worry is that when the list gets big, each user would have to go through the entire "readBy" field in order to determine if the user has read it.
Should I also store within the UserSchema, a field to record all notifications read by the user?
Thank you! Any input is appreciated.