Exercise 1: The Parent Picker — Possible Solution
====================================================================
// routes/admin.js
app.get('/api/pages/candidates', requireAuth, async (req, res) => {
const excludeId = Number(req.query.exclude);
const [rows] = await pool.query('SELECT id, full_path FROM pages WHERE id != ?', [excludeId]);
res.json(rows);
});
WHY THIS WORKS AS AN ANSWER
------------------------------
It correctly excludes the page being edited from its own candidate
list via WHERE id != ? - reparenting a page under itself would
corrupt the tree - and correctly implements the same client-side
filtering convention every sibling course already used.