IMHO:
thumbnail
if it references an avatar should be in user profile. If that's a smiley then it should be at the same level astext
.- if
from.id
is a user ID, then to save space you don't need to repeatnickname
. It can be "injected" in UI or at the time it's sent out somewhere if needed. Sometimes duplicating data can be useful, but in this case it's dubious. discussion
collection might already havefrom
andto
per each discussion. In this case you don't have to repeat user IDs in each message. You could keep onlyfrom
.- If there could be more than 2 people discussing something - group chat, then
from
andto
does not work. You might have to make 2 arrays offrom
andto
. It depends on the type of chat you would have. next
andprevious
: usually I would not have them. You can find a discussion thread bydiscussionId, from.id, to.id
and sort it byposted
. Unless you have some very strange way chat works you can delete these 2 fields.posted
has a date and it's ok, but if you want to save more space date is stored in_id
as well, so you can avoid creating an index and storing an extra field.- eventually, if you decide to remove
nickname
andthumbnail
then you can bringfrom.id
to a level up asfromId
.
Overall it looks good. I'm just nitpicking for performance purposes and small improvements.