Added sorting for events
This commit is contained in:
@@ -36,6 +36,10 @@ const filterEvents = async (req, res) => {
|
||||
{ dayOfWeek: { [Op.gte]: 0 } }
|
||||
]
|
||||
};
|
||||
const order = [
|
||||
['date', 'ASC'],
|
||||
['time', 'ASC']
|
||||
];
|
||||
|
||||
if (request.id === 'all') {
|
||||
const events = await Event.findAll({
|
||||
@@ -46,6 +50,7 @@ const filterEvents = async (req, res) => {
|
||||
{ model: EventType, as: 'eventType' },
|
||||
{ model: ContactPerson, as: 'contactPersons', through: { attributes: [] } }
|
||||
],
|
||||
order: order,
|
||||
logging: console.log // Log the generated SQL query
|
||||
});
|
||||
return res.json({ events });
|
||||
@@ -63,7 +68,7 @@ const filterEvents = async (req, res) => {
|
||||
{ model: EventType, as: 'eventType' },
|
||||
{ model: ContactPerson, as: 'contactPersons', through: { attributes: [] } },
|
||||
],
|
||||
order: ['name', 'date', 'time']
|
||||
order: order,
|
||||
});
|
||||
return res.json({ events });
|
||||
}
|
||||
@@ -96,7 +101,7 @@ const filterEvents = async (req, res) => {
|
||||
{ model: EventType, as: 'eventType' },
|
||||
{ model: ContactPerson, as: 'contactPersons', through: { attributes: [] } }
|
||||
],
|
||||
logging: console.log // Log the generated SQL query
|
||||
order: order,
|
||||
});
|
||||
const displayFields = request.display ? request.display : [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user