polylines tooltip content
This commit is contained in:
@@ -1,25 +1,19 @@
|
||||
// pages/api/talas_v5_DB/pois/deletePoi.js
|
||||
import mysql from "mysql";
|
||||
import mysql from "mysql2/promise";
|
||||
|
||||
// Datenbankkonfiguration
|
||||
const dbConfig = {
|
||||
// Erstellen eines Pools von Datenbankverbindungen
|
||||
const pool = mysql.createPool({
|
||||
host: process.env.DB_HOST,
|
||||
user: process.env.DB_USER,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_NAME,
|
||||
port: process.env.DB_PORT,
|
||||
};
|
||||
|
||||
const connection = mysql.createConnection(dbConfig);
|
||||
connection.connect((err) => {
|
||||
if (err) {
|
||||
console.error("Fehler beim Verbinden:", err.stack);
|
||||
return;
|
||||
}
|
||||
console.log("Verbunden als ID", connection.threadId);
|
||||
waitForConnections: true,
|
||||
connectionLimit: 10,
|
||||
queueLimit: 0,
|
||||
});
|
||||
|
||||
export default function handler(req, res) {
|
||||
export default async function handler(req, res) {
|
||||
if (req.method !== "DELETE") {
|
||||
return res.status(405).json({ error: "Nur DELETE Methode erlaubt" });
|
||||
}
|
||||
@@ -31,15 +25,18 @@ export default function handler(req, res) {
|
||||
}
|
||||
|
||||
const query = "DELETE FROM poi WHERE idPoi = ?";
|
||||
connection.query(query, [id], (error, results) => {
|
||||
if (error) {
|
||||
console.error("Fehler beim Löschen des POI:", error);
|
||||
return res.status(500).json({ error: "Fehler beim Löschen des POI" });
|
||||
}
|
||||
|
||||
try {
|
||||
// Ausführen der Abfrage mit dem Verbindungspool
|
||||
const [results] = await pool.query(query, [id]);
|
||||
|
||||
if (results.affectedRows > 0) {
|
||||
res.json({ message: "POI erfolgreich gelöscht" });
|
||||
res.status(200).json({ message: "POI erfolgreich gelöscht" });
|
||||
} else {
|
||||
res.status(404).json({ error: "POI nicht gefunden" });
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Fehler beim Löschen des POI:", error);
|
||||
res.status(500).json({ error: "Fehler beim Löschen des POI" });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user