N
N
Nick932016-09-26 13:46:14
MongoDB
Nick93, 2016-09-26 13:46:14

How to properly organize the data model?

There is a model: Room - it has an array of messages and an array of participants. It is necessary that the room has a field with the number of new messages for each user.
How can this be properly organized?
While there is an idea, to associate each message with a participant and mark whether the participant read the message or not? But there will be too many connections. Maybe someone has already solved a similar problem and will tell you the best solution?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hoarywolf, 2016-09-26
@Nick93

If messages are read sequentially, then it is possible to store for each user the id of the last read message. Anything with a large id is considered unread.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question