I can't really figure out how to return nested fields within array of objects. Here is my schema:
const chat = new Schema({
id: {
type: String,
required: true
},
channels: [
{
id: {
type: String
},
messages: [
{
author: String,
body: String,
created_at: Date,
_id: false,
avatar: String
}
]
}
]
})
I want to receive 50 channel messages by using chat ID and channel ID from specific range provided by user (0-49, 50-99 and so on).
So in the end I receive array of objects from that channel.
const messages = [{...}, {...}, ...]