I think @Shay_I Idea is that every chat item will be either classified as a parent, while it stores either pointers to the child “grouped” messages or it embeeds them,
For example:
{
_id: '18c9bb4w-03f4-4dc4-b0ba-a3c45c324347',
chatID: 'alternateChat',
type: 'groupedMsgs',
message: 'second message',
senderID: 'first_sender_id',
date: new Date('0001-01-03T01:01:11.001Z'),
numConsecutiveItems: 2
numConsecutiveIds : ["'18c9bb4w-03f4-4dc4-b0ba-a3c45c324347'", "18c9bb4w-03g4-4dc4-b0ba-a3c45c324347"]
}
Or
_id: '18c9bb4w-03f4-4dc4-b0ba-a3c45c324347',
chatID: 'alternateChat',
type: '',
message: 'second message',
senderID: 'first_sender_id',
date: new Date('0001-01-03T01:01:11.001Z'),
numConsecutiveItems: 2
childMessages : [{
_id: '18c9bb4w-03g4-4dc4-b0ba-a3c45c324347',
chatID: 'alternateChat',
type: 'groupedMsgs',
message: 'third message',
senderID: 'first_sender_id',
date: new Date('0001-01-04T01:01:11.001Z')
}]
}
Thanks
Pavel