diff options
author | eug-vs <eug-vs@keemail.me> | 2020-06-26 22:12:37 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-06-26 22:12:37 +0300 |
commit | 24376076e0b2c37baaf196f0664078840aeec91b (patch) | |
tree | 258343f7904d360897b65f0e3408ec61de3b861e /services/polls | |
parent | 7f9df8559139cbda04c480615c4ed25f57c4bbcd (diff) | |
download | which-api-24376076e0b2c37baaf196f0664078840aeec91b.tar.gz |
feat: sort polls by date (newest on top)
Diffstat (limited to 'services/polls')
-rw-r--r-- | services/polls/polls.hooks.ts | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/services/polls/polls.hooks.ts b/services/polls/polls.hooks.ts index 13d6f63..524eaee 100644 --- a/services/polls/polls.hooks.ts +++ b/services/polls/polls.hooks.ts @@ -1,6 +1,16 @@ +import _ from 'lodash'; +import { HookContext } from '@feathersjs/feathers'; import convertPoll from '../../hooks/convertPoll'; +const sort = async (context: HookContext): Promise<HookContext> => { + _.set(context, 'params.query.$sort', { createdAt: - 1}); + return context; +} + export default { + before: { + find: sort + }, after: { all: [convertPoll] } |