Hello Dev Community! 👋
It is officially Day 53 of my unbroken full-stack engineering streak! Yesterday, I decoupled my local file storage using multiple OOP classes. Today, I completely upgraded my persistence engine by moving away from hard-drive JSON text files and connecting a live Relational Database (MySQL) inside Prashant Sir's backend masterclass!
Instead of parsing string arrays on the fly, my system now communicates with a structured SQL server via a high-performance connection pool executing semantic query scripts!
🧠 Key Learnings From Node.js Lecture 27 (MySQL Integration)
As shown in my implementation files across "Screenshot (122).png" and "Screenshot (123).png", refactoring file-based classes into relational database queries makes the system incredibly fast and stable:
1. Connection Pooling with mysql2
Instead of opening and closing single database channels constantly, I setup a connection pool using mysql2/promise inside utils/databaseUtils.js. This creates a set of reusable channels ready to pick up database requests instantly:
javascript
const sql = require('mysql2');
const pool = sql.createPool({
host: 'localhost',
user: 'root',
password: '', // Kept secure for local development
database: 'airbnb'
});
module.exports = pool.promise(); // A look at my new promise-based static lookup method
static fetchAll() {
return db.execute('SELECT * FROM homes');
}










![Pagination: Always a "sort" (of) mistake [bugfix]](https://media2.dev.to/dynamic/image/width=1000,height=420,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdvnqzg9s7l0fx2dewnae.png)

