I want to show this data
[
{ chattext : 'hi', sender_id : 1, receiver_id : 2 }
{ chattext : 'hello', sender_id : 2, receiver_id : 1 }
{ chattext : 'how are you?', sender_id : 1, receiver_id : 2 }
]
how to write the mongoose query for the collections below?
const chatSchema = new mongoose.Schema({
chattext : String,
sender_id : Number,
receiver_id : Number,
})
So, the result will be like
user1 : "hi"
user2 : "hello"
user1 : "how are you?"