Fixed worship edit functionality
This commit is contained in:
@@ -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 = {
|
||||
|
||||
@@ -94,7 +94,7 @@ export default {
|
||||
async fetchWorships() {
|
||||
try {
|
||||
const response = await axios.get('/worships');
|
||||
this.worships = response.data.reverse();
|
||||
this.worships = response.data;
|
||||
} catch (error) {
|
||||
console.error('Fehler beim Abrufen der Gottesdienste:', error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user