Now we added the sort params. Read prev commit

This commit is contained in:
2019-04-16 17:47:12 +02:00
parent 8b39940b2b
commit a30d1d84a5

View File

@@ -19,11 +19,17 @@ function location(req, res) {
}
function list(req, res) {
let sortOption = SORT_OPTIONS[0];
if (req.query.sort && SORT_OPTIONS.includes(req.query.sort)) {
sortOption = req.query.sort;
}
return Adventure
.findAll({
attributes: ['id', 'title', 'subtext', 'dateStart', 'dateEnd', 'locationName'],
order: [
['dateStart', 'ASC'],
['dateStart', sortOption],
]
})
.then(adventure => res.status(200).send(adventure))