如何在带有 node.js 的 typescript-sequelize 中使用“或”选项?

Jun*_*Lee 0 mysql sql node.js sequelize.js typescript

我使用打字稿续集

如何使用findOne({where: {something or something2}}); 我阅读文档,我无法理解帮助我

sci*_*per 7

首先,您必须导入Op

import {Op} from "sequelize";
Run Code Online (Sandbox Code Playgroud)

然后像这样创建你的 where 子句:

findOne({where: {
  value_to_find: {
    [Op.or]: {
      [Op.eq]: something,
      [Op.eq]: something2
    }
  }
}})
Run Code Online (Sandbox Code Playgroud)