{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreiej6sgyczogtsvfy6do2gsauq4zv4qmfba2ztlzwuw5fqtivngflm",
"uri": "at://did:plc:25rdn5elo5izoxrmtis34zuk/app.bsky.feed.post/3mowoyjqy6hv2"
},
"coverImage": {
"$type": "blob",
"ref": {
"$link": "bafkreifapkwcmyw4qbf2flxdnvslymgkla2wsu3a4zwk5vdnqbknyclfsm"
},
"mimeType": "image/webp",
"size": 306570
},
"path": "/ali_hamza_589ec7b3eb6688d/day-68-of-learning-mern-stack-1p2o",
"publishedAt": "2026-06-23T05:35:34.000Z",
"site": "https://dev.to",
"tags": [
"node",
"express",
"mongodb",
"backend"
],
"textContent": "Hello Dev Community! 👋\n\nIt is officially **Day 68** of my full-stack MERN engineering sprint! Yesterday, I configured the polymorphic multi-part entry form. Today, I engineered the operational core of the administrative layer: **The Live Host Dashboard and Real-Time Mongoose Document Eviction Engines!**\n\nBuilding a robust provider matrix requires pulling data collections securely based on ownership variables, mapping them into clean structural list cards, and exposing safe data mutation operations like inline deletion hooks. Today, I wired that entire sync loop flawlessly!\n\n## 🧠 What I Built on Day 68 (Host Management & Deletion Pipes)\n\nAs showcased inside my project staging dashboard in **\"Screenshot (159).jpg\"** , the host operations tier introduces production-grade control tools:\n\n### 1. High-Fidelity Host Dashboard View (`/host/hosthomepage`)\n\nInstead of an unorganized grid, I laid out active property listings (such as _Utsav House_ , _Summer House_ , and _Winter House_) in a beautiful, stacked list matrix:\n\n * Displays dynamic localized asset counters (e.g. `6 listings`) to track overall inventory.\n * Renders real-time content snapshots: matching dynamic images, locations (`Sheikhupura, Pakistan`), and explicit pricing variables (`PKR 9000 / night`) parsed directly from MongoDB.\n\n\n\n### 2. Live Database Deletion Hooks (`Delete` Button Pipeline)\n\nThe star implementation of Day 68 is the document destruction pipeline. When a host clicks the inline \"Delete\" button:\n\n * The controller catches the specific Object ID string bound onto the data structure.\n * It routes the transaction query directly to our Mongoose model hook collection layer.\n * Implements a secure database-level clear command (`findByIdAndDelete` or `deleteOne`), completely wiping the target record and refreshing the listing matrix smoothly!\n\n\n\n## 🛠️ The Backend Execution Logic\n\nTo guarantee structural database reliability, the system leverages isolated document lookups and asynchronous deletion routines, reminiscent of the schema query interceptors configured in my core `homes.js` model structure:\n\n\n javascript\n // Underlying execution model pattern supporting administrative mutations\n exports.postDeleteHome = async (req, res, next) => {\n const homeId = req.body.homeId;\n try {\n await Home.findByIdAndDelete(homeId);\n console.log('Document Evicted from DB Layer Successfully.');\n res.redirect('/host/hosthomepage');\n } catch (err) {\n console.error('Error during document deletion:', err);\n next(err);\n }\n };\n",
"title": "Day 68 of Learning MERN Stack"
}