使用sequelize对数字进行模糊查询

productsModel.findAndCountAll({
	offset: size * (no - 1),
    limit: size,
    order: [
         ['updatedAt', 'DESC']
    ],
    where: {
    	[Op.or]: [
    		{
    			brand: {
    				[Op.like]: `%${keyword}%`
    			}
    		},
	   		sequelize.where(
                sequelize.cast(sequelize.col('products.price'), 'char'),
                {
                    [Op.like]: `%${keyword}%`
                }
			),
   		]
    }
})
发布了80 篇原创文章 · 获赞 31 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/juzipidemimi/article/details/88825666