Sort by publication_date

This commit is contained in:
Chi Vinh Le
2017-11-24 12:41:18 +01:00
parent ac7b4d56a1
commit ec2bf3cb7f
+3 -2
View File
@@ -38,7 +38,7 @@ router.get('/', authorization.needed('ADMIN', 'MODERATOR'), async (req, res, nex
const {
value = '',
field = 'created_at',
field = 'publication_date',
page = 1,
asc = 'false',
filter = 'all',
@@ -46,9 +46,10 @@ router.get('/', authorization.needed('ADMIN', 'MODERATOR'), async (req, res, nex
} = req.query;
try {
const order = (asc === 'true') ? 1 : -1;
const queryOpts = {
sort: {[field]: (asc === 'true') ? 1 : -1},
sort: {[field]: order, 'created_at': order},
skip: (page - 1) * limit,
limit
};