I am breaking my mind up thinking about a good document structure for handling a message app.
I basically need three (or four) types of objects:
Please find my suggestion:
Person : {
person_id: '123',
last_login: 12.06.2008,
online: true
}
Conversation : {
conversation_id: append the greater person_id to the lower person_id, // person_1_id =123 and person_2_id =124 then its 123124
messages: [
{ message_id: 1,
message_text : 'Hi what's up',
sender_id : 123,
receiver_id: 124,
timestamp : 12344567891
},
{ message_id: 2,
message_text : 'fine',
sender_id : 124,
receiver_id: 123,
timestamp : 12344567891
}
]
}