【问题标题】:Getting an error when trying to use postgres typeorm Raw method尝试使用 postgres typeorm Raw 方法时出错
【发布时间】:2021-08-11 03:07:00
【问题描述】:

谁能帮我解决这个问题?

尝试使用 typeorm 在 postgres 中搜索时出错。我正在尝试传递 Raw where,但出现以下错误:

{
  "error": "column \"mm\" does not exist"
}

这是我使用 Raw 的代码:

const appointments = await this.ormRepository.find({
    where: {
        date: Raw(
            dateFieldName =>
            `to_char(${dateFieldName}, MM-YYYY) = '${parsedMonth}-${year}'`,
        ),
    },
});

非常感谢!

【问题讨论】:

    标签: node.js typescript postgresql typeorm


    【解决方案1】:

    你有一个错字:你告诉 Postgres MM 是一个列(因此是错误)。代替MM-YYYY,使用'MM-YYYY'

    【讨论】:

    • 非常感谢,它真的解决了我的问题,我正在学习一门课程,他们使用它没有引号,也许这改变了!
    • 我怀疑语法改变了:我猜你的课程作者犯了一个错误。不会是第一次!
    猜你喜欢
    • 2022-01-12
    • 2013-09-20
    • 2014-06-10
    • 2021-07-29
    • 2012-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多