Fix Bug | relocate data | set basic filter

This commit is contained in:
Mr Swift
2024-08-11 18:50:30 +03:30
parent 9769e2cf63
commit ad04de7832
5 changed files with 42 additions and 6 deletions
+9 -1
View File
@@ -24,8 +24,16 @@ module.exports.getAll = async (req, res) => {
page = req.query.page
page = page * rows - rows
}
const search = req.query?.search ? req.query.search : ""
const score = await Score.find({ userId: req.user_id }).skip(page).limit(rows);
const score = await Score.find({
userId: req.user_id,
$or: [
{ title: { $regex: search, $options: 'i' } },
{ score: { $regex: search, $options: 'i' } },
],
}).skip(page).limit(rows);
const total = Math.ceil((await Score.countDocuments({ userId: req.user_id })))
const user = await User.findById(req.user_id).select('score')