Fixed worship edit functionality

This commit is contained in:
Torsten Schulz
2024-09-06 12:35:54 +02:00
parent 78555bb66a
commit a869f2d16a
2 changed files with 15 additions and 4 deletions

View File

@@ -1,9 +1,18 @@
const { Worship, EventPlace, Sequelize } = require('../models');
const { Op, fn } = require('sequelize'); // Importieren Sie die Operatoren von Sequelize
const { Op, fn, literal } = require('sequelize'); // Importieren Sie die Operatoren von Sequelize
exports.getAllWorships = async (req, res) => {
try {
const worships = await Worship.findAll();
const worships = await Worship.findAll({
where: {
date: {
[Op.gt]: literal("DATE_SUB(NOW(), INTERVAL 4 WEEK)")
},
},
order: [
['date', 'DESC']
],
});
res.status(200).json(worships);
} catch (error) {
res.status(500).json({ message: 'Fehler beim Abrufen der Gottesdienste' });
@@ -51,7 +60,9 @@ exports.deleteWorship = async (req, res) => {
exports.getFilteredWorships = async (req, res) => {
const { location, order } = req.query;
const where = {};
if (order.trim() === '') {
order = 'date DESC';
}
const locations = JSON.parse(location);
if (location && locations.length > 0) {
where.eventPlaceId = {