This commit is contained in:
Aaron William Po
2023-10-07 13:27:01 -04:00
parent 5b287ed2ac
commit 2ee12d351f
21 changed files with 346 additions and 210 deletions

View File

@@ -7,7 +7,7 @@ const CreateBeerPostWithUserSchema = CreateBeerPostValidationSchema.extend({
userId: z.string().cuid(),
});
const createNewBeerPost = async ({
const createNewBeerPost = ({
name,
description,
abv,
@@ -15,32 +15,33 @@ const createNewBeerPost = async ({
styleId,
breweryId,
userId,
}: z.infer<typeof CreateBeerPostWithUserSchema>) => {
const newBeerPost: z.infer<typeof BeerPostQueryResult> =
await DBClient.instance.beerPost.create({
data: {
name,
description,
abv,
ibu,
style: { connect: { id: styleId } },
postedBy: { connect: { id: userId } },
brewery: { connect: { id: breweryId } },
},
select: {
id: true,
name: true,
description: true,
abv: true,
ibu: true,
createdAt: true,
beerImages: { select: { id: true, path: true, caption: true, alt: true } },
brewery: { select: { id: true, name: true } },
style: { select: { id: true, name: true, description: true } },
postedBy: { select: { id: true, username: true } },
},
});
return newBeerPost;
}: z.infer<typeof CreateBeerPostWithUserSchema>): Promise<
z.infer<typeof BeerPostQueryResult>
> => {
return DBClient.instance.beerPost.create({
data: {
name,
description,
abv,
ibu,
style: { connect: { id: styleId } },
postedBy: { connect: { id: userId } },
brewery: { connect: { id: breweryId } },
},
select: {
id: true,
name: true,
description: true,
abv: true,
ibu: true,
createdAt: true,
updatedAt: true,
beerImages: { select: { id: true, path: true, caption: true, alt: true } },
brewery: { select: { id: true, name: true } },
style: { select: { id: true, name: true, description: true } },
postedBy: { select: { id: true, username: true } },
},
});
};
export default createNewBeerPost;