Advice for Chat schema design

Thanks for the suggestion, that makes a lot of sense, then the accompanying query would be the following right?

db.find({ $or: [{ sender: userA, receiver: userB }, { sender: userB, receiver: userA }]}
  .sort({ timestamp: -1 }).skip(offset).limit(limit)

So I would then have to create a multikey index on the sender, receiver and timestamp fields?

1 Like