如何查询"strict"参数?
How to query "strict" parameter?
所以我有下面这段代码:
exports.findAll = (req, res) => {
const title = req.query.title;
var condition = title ? { title: { [Op.like]: `%${title}%` } } : null;
File.findAll({ where: condition })
.then(data => {
res.send(data);
})
.catch(err => {
res.status(500).send({
message:
err.message || "Some error occurred while retrieving files."
});
});
};
如果我 GET http://serverip/api/gta/sa/?title=m4
它 return 是数据库中的另一个文件,首先在其标题中包含 'm4' 然后是标题为 m4 的实际 object .有没有办法强制 GET 向我 return 提供具有确切标题的文件?我不需要收到标题中可能包含 'm4' 的其他文件。
而不是:
title: { [Op.like]: `%${title}%` }
使用:
title: { [Op.eq]: title }
所以我有下面这段代码:
exports.findAll = (req, res) => {
const title = req.query.title;
var condition = title ? { title: { [Op.like]: `%${title}%` } } : null;
File.findAll({ where: condition })
.then(data => {
res.send(data);
})
.catch(err => {
res.status(500).send({
message:
err.message || "Some error occurred while retrieving files."
});
});
};
如果我 GET http://serverip/api/gta/sa/?title=m4
它 return 是数据库中的另一个文件,首先在其标题中包含 'm4' 然后是标题为 m4 的实际 object .有没有办法强制 GET 向我 return 提供具有确切标题的文件?我不需要收到标题中可能包含 'm4' 的其他文件。
而不是:
title: { [Op.like]: `%${title}%` }
使用:
title: { [Op.eq]: title }