【问题标题】:Sequelize: use function in column querySequelize:在列查询中使用函数
【发布时间】:2018-07-05 22:49:25
【问题描述】:

我正在尝试编写以下 SQL 查询的 sequelize:

select * from properties where parse_input(address) LIKE parse_input('%some filter%')

parse_input 是我在我的 postgres 数据库中定义的函数。基本上我想对过滤器和值应用相同的函数,然后运行like 比较。

我尝试过类似的东西:

Sequelize.where(Sequelize.fn('parse_input', Sequelize.col('address')), '$iLike', Sequelize.fn('parse_input', '%some filter%'))

我看到了生成的查询:

...AND "properties"."attribute" = parse_input("address") AND "properties"."comparator" = '$iLike' AND "properties"."logic" = '%some filter%';

但我收到 errorMissingColumn 错误。有什么提示吗?

【问题讨论】:

    标签: node.js postgresql sequelize.js


    【解决方案1】:

    找到解决方案:

    Sequelize.where(
          Sequelize.fn('parse_input', Sequelize.col('address')), {
            [Op.iLike]: Sequelize.fn('parse_input', '%some filter%')
          })
    

    【讨论】:

      猜你喜欢
      • 2018-03-04
      • 1970-01-01
      • 2017-10-21
      • 2021-02-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-22
      • 2017-01-19
      相关资源
      最近更新 更多