mirror of
https://github.com/KevinMidboe/leifsbackend.git
synced 2025-10-29 01:30:21 +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) {
|
||||
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))
|
||||
|
||||
Reference in New Issue
Block a user