This is the json for our message document
{ recipient: 5485ef86028950a880f7f878,
from: 5485ef86028950a880f7f878,
message: 'Hello! Thank you for looking at my question on StackOverflow!',
date: Tue Dec 23 2014 16:24:08 GMT-0600 (CST),
_id: 5499eb8814615b66212018bb }
To view the inbox, I query { recipient: id } and get all the messages to that person. When a user clicks a message, I'd like it to open up a conversation where it queries every single message {from : sender } and { recipient: logged in user } sorted by date. My question is if there's any specific way to model this so that there's a conversation back and fourth, or am I doing this right?
I guess I just described how you'd get an entire conversation history with two users back and fourth, but how would you get an inbox where it only shows the most recent message from every person who sent you a message?
And when you view the conversation, how would you only load the most recent 50 messages or something in the conversation?