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.author !== undefined) updateData.author = body.author if (body.rating !== undefined) updateData.rating = body.rating if (body.title !== undefined) updateData.title = body.title if (body.content !== undefined) updateData.content = body.content if (body.date !== undefined) updateData.date = body.date if (body.verified !== undefined) updateData.verified = body.verified ? 1 : 0 if (body.published !== undefined) updateData.published = body.published ? 1 : 0 if (body.sortOrder !== undefined) updateData.sortOrder = body.sortOrder db.update(schema.reviews).set(updateData).where(eq(schema.reviews.id, id)).run() return { success: true } })