Skip to content

Commit 2437607

Browse files
committed
feat: sort polls by date (newest on top)
1 parent 7f9df85 commit 2437607

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

services/polls/polls.hooks.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1+
import _ from 'lodash';
2+
import { HookContext } from '@feathersjs/feathers';
13
import convertPoll from '../../hooks/convertPoll';
24

5+
const sort = async (context: HookContext): Promise<HookContext> => {
6+
_.set(context, 'params.query.$sort', { createdAt: - 1});
7+
return context;
8+
}
9+
310
export default {
11+
before: {
12+
find: sort
13+
},
414
after: {
515
all: [convertPoll]
616
}

0 commit comments

Comments
 (0)