mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 20:13:49 +00:00
cleanup
This commit is contained in:
@@ -2,9 +2,15 @@ import { z } from 'zod';
|
||||
import DBClient from '@/prisma/DBClient';
|
||||
import BeerStyleQueryResult from './schema/BeerStyleQueryResult';
|
||||
|
||||
const deleteBeerStyleById = async (id: string) => {
|
||||
interface DeleteBeerStyleByIdArgs {
|
||||
beerStyleId: string;
|
||||
}
|
||||
|
||||
const deleteBeerStyleById = async ({
|
||||
beerStyleId,
|
||||
}: DeleteBeerStyleByIdArgs): Promise<z.infer<typeof BeerStyleQueryResult> | null> => {
|
||||
const deleted = await DBClient.instance.beerStyle.delete({
|
||||
where: { id },
|
||||
where: { id: beerStyleId },
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
@@ -18,7 +24,11 @@ const deleteBeerStyleById = async (id: string) => {
|
||||
},
|
||||
});
|
||||
|
||||
return deleted as z.infer<typeof BeerStyleQueryResult> | null;
|
||||
/**
|
||||
* Prisma does not support tuples, so we have to typecast the ibuRange and abvRange
|
||||
* fields to [number, number] in order to satisfy the zod schema.
|
||||
*/
|
||||
return deleted as Awaited<ReturnType<typeof deleteBeerStyleById>>;
|
||||
};
|
||||
|
||||
export default deleteBeerStyleById;
|
||||
|
||||
Reference in New Issue
Block a user