Exercise 1: The Parent Picker — Possible Solution
====================================================================
// src/pages/api/pages/candidates.ts
export const GET: APIRoute = async ({ url }) => {
const excludeId = Number(url.searchParams.get('exclude'));
const candidates = await db
.select({ id: pages.id, fullPath: pages.fullPath })
.from(pages)
.where(ne(pages.id, excludeId));
return new Response(JSON.stringify(candidates), {
headers: { 'Content-Type': 'application/json' },
});
};
// admin page (excerpt) - a plain filtering a