summaryrefslogtreecommitdiff
path: root/src/hooks/ignoreCaseRegex.ts
blob: 3a1ab63d1668e20bc129f20472eb39d9c3977c9b (plain)
1
2
3
4
5
6
7
8
9
10
11
import { HookContext } from '@feathersjs/feathers';
import _ from 'lodash';

const ignoreCaseRegex = async (context: HookContext): Promise<HookContext> => {
  context.params.query = _.mapValues(context.params.query, data => {
    return '$regex' in data ? _.set(data, '$options', 'i') : data;
  });
  return context;
};

export default ignoreCaseRegex;