Sequelize - case-insensitive like

You should use Sequelize.Op :

Table.findAll({
    where: {
        name: {
            [Sequelize.Op.iLike]: searchQuery
        }
    }
})

Don't forget to add % before or after your searchQuery, if you want to make a partial query.

See the docs here


I found the solution:

Table.findAll({
  attributes: ['createdAt', 'col'],
  where: {
    $and:[
      {
        createdAt:{
          $between:[minDate, maxDate]
        }
      },
      Sequelize.where(
        Sequelize.fn('lower', Sequelize.col('col')),
        {
          $like: 'abcd%'
        }
      )
    ]
  }
});

If you're using PostGres, you can use the $iLike operator to search rows (NOT column names like your question asks).

Sequelize Docs

While it doesn't fully address your question, hopefully it will help someone down the road who searches for case-insensitive + Sequelize, which brought me here.

Table.findAll({
    where: {
        createdAt: {
            $between: [minDate, maxDate]
        },
        someOtherColumn: {
            $like: '%mysearchterm%'
        }
    }
})