0

The Sequelize docs show:

Post.findAll({
  where: sequelize.where(sequelize.fn('char_length', sequelize.col('status')), 6)
});

My query:

models.appointment.findAll({
    where: Sequelize.where(Sequelize.fn('char_length', Sequelize.col('department')), 6)
})

Is throwing an error:

Unhandled rejection Error: Invalid value Where {
  attribute: Fn { fn: 'lower', args: [ [Object] ] },
  comparator: '=',
  logic: 6 }

With Sequelize v4.42.x (newest) and mysql. Why would this query be throwing an error like this?

1 Answer 1

1

Can you try it? and let me know. I found a solution at this post

models.appointment.findAll({
    where: Sequelize.where(Sequelize.fn('char_length', Sequelize.col('department')), '=',6)
})
Sign up to request clarification or add additional context in comments.

3 Comments

nice! I feel like that needs to be spelled out better in the docs. Thanks much
I agree. Currently, the document of sequelize is very simple, not cover all case. We need more case study
You can also use Raw where query like - where: { $and: Sequelize.literal("(char_length(department) = 6)") },

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.