Make filters case insensitive

Filters on Forest Admin are case sensitive. If you search for 'forest', 'Forest' wouldn't come up in the results.

If you prefer the search to be case insensitive, you can override the default operators we provide and change their behavior.

In this example, we want to replace the contains operator to make it case insensitive on a SQL project using Sequelize ORM. We will then use the Like vs iLike operators.

You just have to add the following lines to your app.js file.

app.js
...

const Sequelize = require('sequelize');
const Operators = require('forest-express-sequelize/dist/utils/operators');

const options = { Sequelize: Sequelize };
const operators = Operators.getInstance(options);
operators.LIKE = Sequelize.Op.iLike;

...

Before

After

Last updated