javascript - Sequelize - 如何比较日期之间的相等性

标签 javascript node.js typescript orm sequelize.js

如何比较两个日期之间的相等性?
似乎以下不起作用:

const result: SomeModel= SomeModel.findOne( {where: 
            {
                startTime : {
                    [Op.eq] : someDateTime
                }
            }
        });

最佳答案

请试试

  const result: SomeModel= SomeModel.findOne( {where: 
                {
                    startTime : {
                        [Op.and] : someDateTime
                    }
                }
            });

这是可以执行的所有操作的列表
Project.findAll({
  where: {
    id: {
      [Op.and]: {a: 5},           // AND (a = 5)
      [Op.or]: [{a: 5}, {a: 6}],  // (a = 5 OR a = 6)
      [Op.gt]: 6,                // id > 6
      [Op.gte]: 6,               // id >= 6
      [Op.lt]: 10,               // id < 10
      [Op.lte]: 10,              // id <= 10
      [Op.ne]: 20,               // id != 20
      [Op.between]: [6, 10],     // BETWEEN 6 AND 10
      [Op.notBetween]: [11, 15], // NOT BETWEEN 11 AND 15
      [Op.in]: [1, 2],           // IN [1, 2]
      [Op.notIn]: [1, 2],        // NOT IN [1, 2]
      [Op.like]: '%hat',         // LIKE '%hat'
      [Op.notLike]: '%hat',       // NOT LIKE '%hat'
      [Op.iLike]: '%hat',         // ILIKE '%hat' (case insensitive)  (PG only)
      [Op.notILike]: '%hat',      // NOT ILIKE '%hat'  (PG only)
      [Op.overlap]: [1, 2],       // && [1, 2] (PG array overlap operator)
      [Op.contains]: [1, 2],      // @> [1, 2] (PG array contains operator)
      [Op.contained]: [1, 2],     // <@ [1, 2] (PG array contained by operator)
      [Op.any]: [2,3]            // ANY ARRAY[2, 3]::INTEGER (PG only)
    },
    status: {
      [Op.not]: false           // status NOT FALSE
    }
  }
})

关于javascript - Sequelize - 如何比较日期之间的相等性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61615632/

相关文章:

javascript - Vue - 调度完成后调用 store getter?

javascript - 如何以编程方式触发 Vuetify.js 组件的链式 react ?

node.js - 存储静态内容时应用程序大小重要吗?

javascript - 如何在 TypeScript 中新建一个类

typescript - 当定义需要导入语句时,如何扩展现有接口(interface)?

javascript - 使用 AngularJS 访问另一个函数的变量

javascript - 更改亮度滤镜

javascript - 在客户端从服务器获取值

node.js - 异步但顺序请求的模式

javascript - Angular 6 主题订阅不起作用