1

can anyone help me with this?

I'm having a error when trying to search in postgres with typeorm. I'm trying to pass a Raw where, but I'm getting the following error:

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

This is my code where I use Raw:

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

Thanks so much!

1 Answer 1

1

You have a typo: you've told Postgres that MM is a column (thus the error). Instead of MM-YYYY, use 'MM-YYYY'.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks so much man, it really solve my problem, I'm following a course and they use it without the quotes, maybe this changed!
I doubt the syntax changed: I guessing your course writers made a mistake. Wouldn't be the first time!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.