简体   繁体   English

使用 NOT LIKE where 子句对查询进行 Sequelize

[英]Sequelize query with NOT LIKE where clause

How can I create a sql query involving a WHERE NOT LIKE clause using Sequelize.js(Version 1.7.0)?如何使用 Sequelize.js(1.7.0 版)创建涉及WHERE NOT LIKE子句的 sql 查询? The final SQL query should look like this最终的 SQL 查询应如下所示

SELECT * FROM transfers WHERE address NOT LIKE '%bank%' SELECT * FROM transfers WHERE address NOT LIKE '%bank%'

This is the code that I have这是我拥有的代码

findToProcess: function(callback) {
      var query;
      query = {
        where: {
          status: 1
          address: 'Bank Address',

        },
        order: [["created_at", "ASC"]]
      };
      return Transfer.findAll(query).complete(callback);

Squelize version 2, such a query can be made using $notLike: '%hat' operator. Squelize 版本 2,可以使用$notLike: '%hat'运算符进行此类查询。 Sadly I can't update my sequelize version.遗憾的是,我无法更新我的续集版本。 Is there any way to get this done using sequelize v1.7.0?有没有办法使用 sequelize v1.7.0 来完成这项工作?

Sequelize Query We have achive to follow sequelize document use given examples Sequelize Query 我们已经按照给定的示例使用了sequelize 文档

const { Op } = require("sequelize");
where: { status: 1,
       address: {
        [Op.like]: '%hat', // LIKE '%hat'
        [Op.notLike]: '%hat'// NOT LIKE '%hat'
       }
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM