add date picker
This commit is contained in:
@@ -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({
|
||||
|
Reference in New Issue
Block a user