aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/polls/polls.hooks.ts10
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]
}