Update where.js

This commit is contained in:
Hasta 2022-11-30 16:48:23 +01:00 committed by GitHub
parent 5453885f7a
commit b210dac830
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,6 +25,8 @@ const OPERATORS = [
'$between',
'$startsWith',
'$endsWith',
'$startsWithi',
'$endsWithi',
'$contains',
'$notContains',
'$containsi',
@ -283,10 +285,18 @@ const applyOperator = (qb, column, operator, value) => {
qb.where(column, 'like', `${value}%`);
break;
}
case '$startsWithi': {
qb.whereRaw(`${fieldLowerFn(qb)} LIKE LOWER(?)`, [column, `${value}%`]);
break;
}
case '$endsWith': {
qb.where(column, 'like', `%${value}`);
break;
}
case '$endsWithi': {
qb.whereRaw(`${fieldLowerFn(qb)} LIKE LOWER(?)`, [column, `%${value}`]);
break;
}
case '$contains': {
qb.where(column, 'like', `%${value}%`);
break;