Website/db/app/item-props/mutations/deleteItemProp.ts

15 lines
405 B
TypeScript
Raw Normal View History

2022-05-06 21:05:02 -04:00
import { resolver } from "blitz"
import db from "db"
import { z } from "zod"
const DeleteItemProp = z.object({
id: z.number(),
})
export default resolver.pipe(resolver.zod(DeleteItemProp), resolver.authorize(), async ({ id }) => {
// TODO: in multi-tenant app, you must add validation to ensure correct tenant
const itemProp = await db.itemProp.deleteMany({ where: { id } })
return itemProp
})