Feat: Add create brewery comments and brewery cluster map

This commit is contained in:
Aaron William Po
2023-04-30 23:09:03 -04:00
parent b3b1d5b6d1
commit adf1b55d10
13 changed files with 452 additions and 165 deletions

View 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;