From 1da159d1102bf0ded9ce50d447c821258c7be800 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sat, 17 Apr 2021 19:57:19 +0300 Subject: feat: add ignoreCaseRegex hook --- src/hooks/ignoreCaseRegex.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/hooks/ignoreCaseRegex.ts (limited to 'src/hooks/ignoreCaseRegex.ts') diff --git a/src/hooks/ignoreCaseRegex.ts b/src/hooks/ignoreCaseRegex.ts new file mode 100644 index 0000000..e996000 --- /dev/null +++ b/src/hooks/ignoreCaseRegex.ts @@ -0,0 +1,11 @@ +import { HookContext } from '@feathersjs/feathers'; +import _ from 'lodash'; + +const ignoreCaseRegex = async (context: HookContext): Promise => { + context.params.query = _.mapValues(context.params.query, (data, key) => { + return key.startsWith('$') ? data : _.set(data, '$options', 'i'); + }); + return context; +}; + +export default ignoreCaseRegex; -- cgit v1.2.3