Website/db/app/item-prefabs/mutations/deleteItemPrefab.ts

19 lines
431 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 DeleteItemPrefab = z.object({
id: z.number(),
})
export default resolver.pipe(
resolver.zod(DeleteItemPrefab),
resolver.authorize(),
async ({ id }) => {
// TODO: in multi-tenant app, you must add validation to ensure correct tenant
const itemPrefab = await db.itemPrefab.deleteMany({ where: { id } })
return itemPrefab
}
)