mirror of
https://github.com/KevinMidboe/leifsbackend.git
synced 2025-10-29 09:40:20 +00:00
Now we added the sort params. Read prev commit
This commit is contained in:
@@ -19,11 +19,17 @@ function location(req, res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function list(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
|
return Adventure
|
||||||
.findAll({
|
.findAll({
|
||||||
attributes: ['id', 'title', 'subtext', 'dateStart', 'dateEnd', 'locationName'],
|
attributes: ['id', 'title', 'subtext', 'dateStart', 'dateEnd', 'locationName'],
|
||||||
order: [
|
order: [
|
||||||
['dateStart', 'ASC'],
|
['dateStart', sortOption],
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
.then(adventure => res.status(200).send(adventure))
|
.then(adventure => res.status(200).send(adventure))
|
||||||
|
|||||||
Reference in New Issue
Block a user