shellphone.app/app/phone-numbers/queries/get-customer-phone-number.ts
2021-07-31 22:33:18 +08:00

20 lines
480 B
TypeScript

import { resolver } from "blitz"
import db from "db"
import { z } from "zod"
const GetCustomerPhoneNumber = z.object({
// This accepts type of undefined, but is required at runtime
customerId: z.string().optional().refine(Boolean, "Required"),
})
export default resolver.pipe(resolver.zod(GetCustomerPhoneNumber), async ({ customerId }) =>
db.phoneNumber.findFirst({
where: { customerId },
select: {
id: true,
phoneNumber: true,
phoneNumberSid: true,
},
})
)