-1
I have a route that receives a parameter in the format yyyy-mm(year-mes), I get this in the function below and do a search in my mongoDB database, but returns []:
const findYearMonth = async (req, res) => {
try {
let data = [];
const period = req.params.period;
//console.log(`${typeof (period)} : ${period}`);
data = await TransactionModel.find({yearMonth: period});
JSON.stringify(data);
if (!data) {
res.status(500).send('Ocorreu um erro ao buscar valores');
}
else {
res.send(data);
}
}catch (error) {
res.send('Ocorreu um erro ao tentar encontrar as entradas:' + error);
}
};