add date picker

This commit is contained in:
Nikola Petrov
2023-10-06 18:18:24 +02:00
parent dfb76ed5f0
commit 1a1318c048
2 changed files with 15 additions and 1 deletions

View File

@@ -3,7 +3,20 @@ module.exports = {
list: async function (req, res) {
try {
const transactions = await cashTransactionModel.find({}, { _id: 0, __v: 0 });
var transactions;
const date = req.body.date;
if (date) {
const splitDate = date.split('-');
var year = splitDate[0];
var month = splitDate[1];
year = parseInt(year);
month = parseInt(month);
transactions = await cashTransactionModel.find({ year, month }, { _id: 0, __v: 0 });
} else {
transactions = await cashTransactionModel.find({}, { _id: 0, __v: 0 });
}
return res.json(transactions);
} catch (err) {
return res.status(500).json({