How to request data from mongodb (mongoose) from subdocument within the interval "from" and "to"? How to request data from mongodb (mongoose) from subdocument within the interval "from" and "to"? mongoose mongoose

How to request data from mongodb (mongoose) from subdocument within the interval "from" and "to"?


don't need the elementMatch function , you can query from subdocument as :

function request(symbol, from, to) {    return model.findOne({            symbol : symbol,            'data.timestamp' : { $gte: from, $lt: to }        }    }).then(res => res.data)}