14 lines
511 B
TypeScript
14 lines
511 B
TypeScript
export default defineEventHandler(async (event) => {
|
|
const input = await readValidBody(event, newReviewSchema)
|
|
|
|
// The review's date is a lookup of the book's read_date, so the date is saved on the book
|
|
await updateRow(event, await booksTableId(event), input.bookId, { read_date: input.date })
|
|
|
|
const row = await createRow<ReviewRow>(event, diaryTable(event, 'reviews'), {
|
|
books: [input.bookId],
|
|
review: input.text,
|
|
medium: await mediumOptionId(event, 'book')
|
|
})
|
|
return toReview(row)
|
|
})
|