From afa1d1371c10878f395f95279beac5bb0aec6963 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sat, 20 Mar 2021 19:56:54 +0300 Subject: feat: add default sort by createdAt --- src/hooks/sortByDate.ts | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/hooks/sortByDate.ts (limited to 'src/hooks') diff --git a/src/hooks/sortByDate.ts b/src/hooks/sortByDate.ts new file mode 100644 index 0000000..9dd1222 --- /dev/null +++ b/src/hooks/sortByDate.ts @@ -0,0 +1,8 @@ +import _ from 'lodash'; +import { HookContext } from '@feathersjs/feathers'; + +export default async (context: HookContext): Promise => { + _.set(context, 'params.query.$sort', { createdAt: -1 }); + return context; +}; + -- cgit v1.2.3