perf: admin

This commit is contained in:
archer
2023-06-13 11:49:26 +08:00
parent fc3c360985
commit 89e7c1abca
4 changed files with 119 additions and 10 deletions

View File

@@ -10,7 +10,21 @@ export const useKbRoute = (app) => {
const order = req.query._order === 'DESC' ? -1 : 1;
const sort = req.query._sort || '_id';
const tag = req.query.tag || '';
const where = { tags: { $elemMatch: { $regex: tag, $options: 'i' } } };
const name = req.query.name || '';
const where = {
...(name
? {
name: { $regex: name, $options: 'i' }
}
: {}),
...(tag
? {
tags: { $elemMatch: { $regex: tag, $options: 'i' } }
}
: {})
};
console.log(where);
const kbsRaw = await Kb.find(where)
.skip(start)