mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 10:42:08 +00:00
cleanup
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user