20 lines
452 B
TypeScript
20 lines
452 B
TypeScript
![]() |
import { resolver } from "blitz"
|
||
|
import db from "db"
|
||
|
import { z } from "zod"
|
||
|
|
||
|
const UpdateItemProp = z.object({
|
||
|
id: z.number(),
|
||
|
name: z.string(),
|
||
|
})
|
||
|
|
||
|
export default resolver.pipe(
|
||
|
resolver.zod(UpdateItemProp),
|
||
|
resolver.authorize(),
|
||
|
async ({ id, ...data }) => {
|
||
|
// TODO: in multi-tenant app, you must add validation to ensure correct tenant
|
||
|
const itemProp = await db.itemProp.update({ where: { id }, data })
|
||
|
|
||
|
return itemProp
|
||
|
}
|
||
|
)
|