我有一个单词数组,我想用它搜索数据库Sequalize ['orange', 'apple', 'apricot'] 如何实现这样的查询
['orange', 'apple', 'apricot']
SELECT * FROM Table WHERE text LIKE '%orange%' OR text LIKE '%apple%' OR text LIKE '%apricot%'
与 Sequalize ?
Sequalize
xxls0lw81#
像这样:
const { Op } = require('Sequelize') ... TableModel.findAll({ where: { [Op.or]: [{ text: { [Op.iLike]: '%orange%' } }, { text: { [Op.iLike]: '%apple%' } }, { text: { [Op.iLike]: '%apricot%' } }] } })
1条答案
按热度按时间xxls0lw81#
像这样: