import { eq } from 'drizzle-orm' import { useDB, schema } from '../../../utils/db.js' import { requireAdmin } from '../../../utils/auth.js' export default defineEventHandler(async (event) => { requireAdmin(event) const id = Number(getRouterParam(event, 'id')) const body = await readBody(event) const db = useDB() const updateData = {} if (body.title !== undefined) updateData.title = body.title if (body.category !== undefined) updateData.category = body.category if (body.location !== undefined) updateData.location = body.location if (body.description !== undefined) updateData.description = body.description if (body.image !== undefined) updateData.image = body.image if (body.orientation !== undefined) updateData.orientation = body.orientation if (body.published !== undefined) updateData.published = body.published ? 1 : 0 if (body.sortOrder !== undefined) updateData.sortOrder = body.sortOrder db.update(schema.galleryItems).set(updateData).where(eq(schema.galleryItems.id, id)).run() return { success: true } })