muss noch für update der Bereich Marker gearbeitet werden

This commit is contained in:
ISA
2024-12-20 14:50:30 +01:00
parent 6155561f14
commit a82a92e89a
3 changed files with 28 additions and 26 deletions

View File

@@ -1,8 +1,8 @@
// /pages/api/talas_v5_DB/bereich/updateBereich.js
import getPool from "../../../utils/mysqlPool"; // Singleton-Pool importieren
import getPool from "../../../utils/mysqlPool";
export default async function handler(req, res) {
const pool = getPool(); // Singleton-Pool verwenden
const pool = getPool();
if (req.method !== "PUT") {
return res.status(405).json({ error: "Nur PUT Methode erlaubt" });
@@ -22,14 +22,16 @@ export default async function handler(req, res) {
const [result] = await connection.query(query, [x, y, idLocation, idMap]);
if (result.affectedRows > 0) {
res.status(200).json({ success: true, message: "Koordinaten erfolgreich aktualisiert" });
return res.status(200).json({ success: true, message: "Koordinaten erfolgreich aktualisiert" });
} else {
res.status(404).json({ error: "Kein Eintrag gefunden, der aktualisiert werden konnte" });
return res.status(404).json({ error: "Kein Eintrag gefunden, der aktualisiert werden konnte" });
}
} catch (error) {
console.error("Fehler beim Aktualisieren der Koordinaten:", error);
res.status(500).json({ error: "Interner Serverfehler beim Aktualisieren der Koordinaten" });
return res.status(500).json({ error: "Interner Serverfehler beim Aktualisieren der Koordinaten" });
} finally {
if (connection) connection.release();
if (connection) {
connection.release();
}
}
}