Fix Bug | relocate data | set basic filter
This commit is contained in:
@@ -58,8 +58,17 @@ module.exports.getAllForUser = async (req, res) => {
|
||||
page = req.query.page
|
||||
page = page * rows - rows
|
||||
}
|
||||
const search = req.query?.search ? req.query.search : ""
|
||||
|
||||
const data = await Withdraw.find({ userId: req.user_id }).skip(page).limit(rows).sort({ created_at: -1 });
|
||||
|
||||
const data = await Withdraw.find({
|
||||
userId: req.user_id,
|
||||
$or: [
|
||||
{ amount: { $regex: search, $options: 'i' } },
|
||||
{ dollarAmount: { $regex: search, $options: 'i' } },
|
||||
{ trackingNumber: { $regex: search, $options: 'i' } },
|
||||
],
|
||||
}).skip(page).limit(rows).sort({ created_at: -1 });
|
||||
const total = Math.ceil((await Withdraw.countDocuments({ userId: req.user_id })))
|
||||
res.status(201).json({ data, total })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user