mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 10:42:08 +00:00
Feat: Add create brewery comments and brewery cluster map
This commit is contained in:
33
src/services/BreweryComment/createNewBreweryComment.ts
Normal file
33
src/services/BreweryComment/createNewBreweryComment.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import DBClient from '@/prisma/DBClient';
|
||||
import { z } from 'zod';
|
||||
import CreateCommentValidationSchema from '../types/CommentSchema/CreateCommentValidationSchema';
|
||||
|
||||
const CreateNewBreweryCommentServiceSchema = CreateCommentValidationSchema.extend({
|
||||
userId: z.string().uuid(),
|
||||
breweryPostId: z.string().uuid(),
|
||||
});
|
||||
|
||||
const createNewBreweryComment = async ({
|
||||
content,
|
||||
rating,
|
||||
breweryPostId,
|
||||
userId,
|
||||
}: z.infer<typeof CreateNewBreweryCommentServiceSchema>) => {
|
||||
return DBClient.instance.breweryComment.create({
|
||||
data: {
|
||||
content,
|
||||
rating,
|
||||
breweryPost: { connect: { id: breweryPostId } },
|
||||
postedBy: { connect: { id: userId } },
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
content: true,
|
||||
rating: true,
|
||||
postedBy: { select: { id: true, username: true } },
|
||||
createdAt: true,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export default createNewBreweryComment;
|
||||
Reference in New Issue
Block a user