I'm not well-versed with Mongo, so please excuse any ignorance here!
I want to add a seenMessages object to each user to determine which messages the user has read or not, as determined by the presence (or absence) of the message's unique ID, similar to something like:
// key in user object
seenMessages: {
i3d4Fh87: 'i3d4Fh87',
hfy7FDE9: 'hfy7FDE9',
}
The idea is to check the object for that key and, if unable to locate, the message is then considered 'unseen'. Upon viewing the message, the message ID is then added to the seenMessages object, at which point it will then be considered 'seen'.
Is there a way to achieve this in Mongo? Namely in the update stage as well as just creating a field as an empty object, Schema.Types.Mixed just seems to produce an array containing null.