Browse Source

Fix "Error: Invalid value { like: '%A%' }"

master
Menci 6 years ago
parent
commit
f31c0020b7
  1. 6
      modules/api_v2.js
  2. 2
      modules/problem.js

6
modules/api_v2.js

@ -30,7 +30,7 @@ app.get('/api/v2/search/users/:keyword*?', async (req, res) => {
conditions.push({ id: uid });
}
if (keyword != null && String(keyword).length >= 2) {
conditions.push({ username: { like: `%${req.params.keyword}%` } });
conditions.push({ username: { $like: `%${req.params.keyword}%` } });
}
if (conditions.length === 0) {
res.send({ success: true, results: [] });
@ -56,7 +56,7 @@ app.get('/api/v2/search/problems/:keyword*?', async (req, res) => {
let keyword = req.params.keyword || '';
let problems = await Problem.query(null, {
title: { like: `%${req.params.keyword}%` }
title: { $like: `%${req.params.keyword}%` }
}, [['id', 'asc']]);
let result = [];
@ -89,7 +89,7 @@ app.get('/api/v2/search/tags/:keyword*?', async (req, res) => {
let keyword = req.params.keyword || '';
let tags = await ProblemTag.query(null, {
name: { like: `%${req.params.keyword}%` }
name: { $like: `%${req.params.keyword}%` }
}, [['name', 'asc']]);
let result = tags.slice(0, syzoj.config.page.edit_problem_tag_list);

2
modules/problem.js

@ -94,7 +94,7 @@ app.get('/problems/search', async (req, res) => {
let where = {
$or: {
title: { like: `%${req.query.keyword}%` },
title: { $like: `%${req.query.keyword}%` },
id: id
}
};

Loading…
Cancel
Save