【发布时间】:2021-04-12 08:26:48
【问题描述】:
我要搜索所有列并显示搜索结果。
我是续集的新手,所以使用此代码来执行此操作,但是这里它正在检查完整匹配
我还想显示部分匹配的详细信息
我是如何做到这一点的?
router.post("/search-employees", async (req, res) => {
const searchTerm = req.body.searchTerm;
try {
const resp = await employee.findAll({
where: {
[Op.or]: [
{ name: searchTerm },
{ age: searchTerm },
{ country: searchTerm },
{ position: searchTerm },
{ wage: searchTerm },
],
},
});
res.status(200).send(resp);
} catch (e) {
res.status(400).send(e);
}
});
【问题讨论】:
标签: javascript node.js express sequelize.js