¿Cómo escribiría una consulta que verifique el createdAt y encuentre todos los objetos entre 2022-05-22 y 2022-06-22? Probé el siguiente código/API, pero no devolvió los datos correctos:
getPoDetails = async (req, res, next) => { try { let fromDate = req.query.fromDate; let toDate = req.query.toDate; var findQry = {}; if(fromDate && toDate) { findQry.createdAt = {$gte: new Date(fromDate), $lte: new Date(toDate)}; } allmodels.poDetailsModel.find(findQry) .then(data => res.status(200).send(data)) .catch(err => res.status(400).send(err)); } catch (error) { next(error); } }Enlace API: localhost:8000/getPoDetails?fromDate=2022-05-22&toDate=2022-06-22