I'm using MongoDB in a Node.js app with mongoose.
I have a collection in my DB, that can be described with the following schema:
{
id: String,
name: String,
indicators: [{
date: Date,
value: Number
}]
}
where id is unique, and each document has a lot of indicators in it.
I want to able to query the collection according to attributes of the indicators array. For example: sort the array by date or limit the amount of results in the array (possibly with an offset).
How can I do that?