Enhance backend and frontend setup with MySQL integration, Docker configurations, and toast notifications
- Updated .gitignore to include additional environment and build files - Configured Dockerfiles for backend and frontend with npm install and port exposure - Added MySQL connection pool and query function in backend services - Implemented form submission with toast notifications in MainForm component - Updated package.json and package-lock.json for new dependencies - Enhanced routing and layout in frontend with toast notifications
This commit is contained in:
34
backend/services/database.js
Normal file
34
backend/services/database.js
Normal file
@@ -0,0 +1,34 @@
|
||||
import mysql from "mysql2";
|
||||
import dotenv from "dotenv";
|
||||
dotenv.config();
|
||||
|
||||
// Create a MySQL connection pool using environment variables for configuration
|
||||
const pool = mysql
|
||||
.createPool({
|
||||
host: process.env.DB_HOST,
|
||||
user: process.env.DB_USER,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_NAME,
|
||||
})
|
||||
.promise();
|
||||
|
||||
export async function query(params) {
|
||||
const [result] = await pool.query(
|
||||
"UPDATE lose SET vorname = ?, nachname = ?, adresse = ?, plz = ?, email = ? WHERE losnummer = ? AND vorname IS NULL AND nachname IS NULL AND adresse IS NULL AND plz IS NULL AND email IS NULL",
|
||||
[
|
||||
params.vorname,
|
||||
params.nachname,
|
||||
params.adresse,
|
||||
params.plz,
|
||||
params.email,
|
||||
params.losnummer,
|
||||
]
|
||||
);
|
||||
|
||||
if (result.affectedRows > 0) {
|
||||
console.log("Update successful:", result);
|
||||
return { success: true };
|
||||
} else {
|
||||
return { success: false };
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user