Added order
This commit is contained in:
@@ -10,7 +10,8 @@ const getAllContactPersons = async (req, res) => {
|
||||
as: 'positions',
|
||||
through: { attributes: [] }
|
||||
}
|
||||
]
|
||||
],
|
||||
order: ['name']
|
||||
});
|
||||
res.json(contactPersons);
|
||||
} catch (error) {
|
||||
@@ -74,13 +75,10 @@ const deleteContactPerson = async (req, res) => {
|
||||
const filterContactPersons = async (req, res) => {
|
||||
try {
|
||||
const { config: configString } = req.body;
|
||||
console.log(configString, typeof configString);
|
||||
const config = JSON.parse(configString);
|
||||
const where = {};
|
||||
const having = [];
|
||||
|
||||
console.log(config, typeof config);
|
||||
console.log(config.selection);
|
||||
if (config.selection.id && config.selection.id === 'all') {
|
||||
// No additional filter needed for "all"
|
||||
} else if (config.selection.id) {
|
||||
@@ -116,6 +114,7 @@ const filterContactPersons = async (req, res) => {
|
||||
},
|
||||
],
|
||||
having: having.length > 0 ? { [Op.and]: having } : undefined,
|
||||
order: ['name']
|
||||
});
|
||||
|
||||
res.json(contactPersons);
|
||||
|
||||
@@ -10,7 +10,8 @@ const getAllEvents = async (req, res) => {
|
||||
{ model: EventPlace, as: 'eventPlace' },
|
||||
{ model: EventType, as: 'eventType' },
|
||||
{ model: ContactPerson, as: 'contactPersons', through: { attributes: [] } }
|
||||
]
|
||||
],
|
||||
order: ['name', 'date', 'time']
|
||||
});
|
||||
res.json(events);
|
||||
} catch (error) {
|
||||
@@ -62,6 +63,7 @@ const filterEvents = async (req, res) => {
|
||||
{ model: EventType, as: 'eventType' },
|
||||
{ model: ContactPerson, as: 'contactPersons', through: { attributes: [] } }
|
||||
],
|
||||
order: ['name', 'date', 'time']
|
||||
});
|
||||
return res.json({ events });
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@ const { EventPlace } = require('../models');
|
||||
|
||||
const getAllEventPlaces = async (req, res) => {
|
||||
try {
|
||||
const eventPlaces = await EventPlace.findAll();
|
||||
const eventPlaces = await EventPlace.findAll({
|
||||
order: [['name', 'ASC']]
|
||||
});
|
||||
res.json(eventPlaces);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: 'Failed to fetch event places' });
|
||||
|
||||
@@ -2,7 +2,7 @@ const { EventType } = require('../models');
|
||||
|
||||
const getAllEventTypes = async (req, res) => {
|
||||
try {
|
||||
const eventTypes = await EventType.findAll();
|
||||
const eventTypes = await EventType.findAll({ order: [['caption', 'ASC']]});
|
||||
res.json(eventTypes);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: 'Failed to fetch event types' });
|
||||
|
||||
@@ -37,7 +37,7 @@ exports.saveImageDetails = async (req, res) => {
|
||||
|
||||
exports.getImages = async (req, res) => {
|
||||
try {
|
||||
const images = await Image.findAll();
|
||||
const images = await Image.findAll({ order: [['title', 'ASC']]});
|
||||
res.status(200).json(images);
|
||||
} catch (error) {
|
||||
console.error('Fehler beim Abrufen der Bilder:', error);
|
||||
|
||||
@@ -9,7 +9,8 @@ const getAllInstitutions = async (req, res) => {
|
||||
as: 'contactPersons',
|
||||
through: { attributes: [] }
|
||||
}
|
||||
]
|
||||
],
|
||||
order: [['name', 'ASC']]
|
||||
});
|
||||
res.json(institutions);
|
||||
} catch (error) {
|
||||
|
||||
@@ -2,7 +2,7 @@ const { Position } = require('../models');
|
||||
|
||||
const getAllPositions = async (req, res) => {
|
||||
try {
|
||||
const positions = await Position.findAll();
|
||||
const positions = await Position.findAll({order: [['caption', 'ASC']]});
|
||||
res.json(positions);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: 'Failed to fetch positions' });
|
||||
|
||||
@@ -2,7 +2,7 @@ const { User } = require('../models');
|
||||
|
||||
exports.getAllUsers = async (req, res) => {
|
||||
try {
|
||||
const users = await User.findAll();
|
||||
const users = await User.findAll({order: [['name', 'ASC']]});
|
||||
res.status(200).json(users);
|
||||
} catch (error) {
|
||||
res.status(500).json({ message: 'Error fetching users' });
|
||||
|
||||
@@ -63,7 +63,6 @@ exports.getFilteredWorships = async (req, res) => {
|
||||
[Op.gte]: new Date(), // Only include events from today onwards
|
||||
};
|
||||
|
||||
console.log(where, order);
|
||||
try {
|
||||
const worships = await Worship.findAll({
|
||||
where,
|
||||
|
||||
Reference in New Issue
Block a user