typescript - Sequelize 更新不接受 `null` 作为 typescript 的属性

标签 typescript sequelize.js

我收到以下数据库请求的奇怪错误:

RequestApp.update({
    is_selected: false
  }, {
    transaction: dbTransaction,
    where: {
      is_selected: null,
      request_id: request.id,
      user_id: {
        [db.Sequelize.Op.ne]: id
      }
    }
  })

我得到的错误如下:

错误 TS2322:类型 'null' 不能分配给类型 'Object | WhereOptions[]'。

从技术上讲,我可以通过设置 null as any 来消除错误,但似乎应该有一种方法可以将其直接设置为 where 子句。

有没有办法在不明确覆盖数据值的情况下做到这一点?

最佳答案

可以用:

is_selected: { [Op.eq]: null }

关于typescript - Sequelize 更新不接受 `null` 作为 typescript 的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54869498/

相关文章:

javascript - Typescript - 在解构构造函数中将属性设为公共(public)

typescript - 带有可折叠列表的 Angular2 sidenav : keeping only one sublist open

javascript - 如何扩展 Sequelize 模型

node.js - ORDER BY Sequelize nodeJS

node.js - 尝试创建新用户

angular - 具有用户定义的 InjectionToken 的 DI 无法在启用 AOT 的情况下工作

typescript - 在没有 "any."的 TypeScript 中创建 JSON 接口(interface)

sequelize.js - sequelize.showAllTables 不是函数

javascript - Angular 6 : Unable to access js variable in template getting async data

node.js - 不能在另一个 Controller 中使用 req.user