diff options
author | eug-vs <eug-vs@keemail.me> | 2021-03-20 19:56:54 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2021-03-20 19:56:54 +0300 |
commit | afa1d1371c10878f395f95279beac5bb0aec6963 (patch) | |
tree | 723537bbdf05c6bdc293f3de659392f36bc67992 /src/hooks/sortByDate.ts | |
parent | 3188db84ca5a0ba6eebbc8ea4cd87d4aa3cebb89 (diff) | |
download | commercel-api-afa1d1371c10878f395f95279beac5bb0aec6963.tar.gz |
feat: add default sort by createdAt
Diffstat (limited to 'src/hooks/sortByDate.ts')
-rw-r--r-- | src/hooks/sortByDate.ts | 8 |
1 files changed, 8 insertions, 0 deletions
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<HookContext> => { + _.set(context, 'params.query.$sort', { createdAt: -1 }); + return context; +}; + |