Refactor and formatting

This commit is contained in:
Aaron William Po
2023-09-29 20:48:19 -04:00
parent 39980eb8c3
commit eb6dbb2115
23 changed files with 152 additions and 128 deletions

View File

@@ -2,19 +2,14 @@ import DBClient from '@/prisma/DBClient';
import { z } from 'zod';
import GetUserSchema from '../User/schema/GetUserSchema';
const createBeerPostLike = async ({
id,
user,
}: {
interface CreateBeerPostLikeArgs {
id: string;
user: z.infer<typeof GetUserSchema>;
}) => {
return DBClient.instance.beerPostLike.create({
data: {
beerPost: { connect: { id } },
likedBy: { connect: { id: user.id } },
},
}
const createBeerPostLike = async ({ id, user }: CreateBeerPostLikeArgs) =>
DBClient.instance.beerPostLike.create({
data: { beerPost: { connect: { id } }, likedBy: { connect: { id: user.id } } },
});
};
export default createBeerPostLike;

View File

@@ -1,11 +1,6 @@
import DBClient from '@/prisma/DBClient';
const getBeerPostLikeCount = async (beerPostId: string) => {
const count = await DBClient.instance.beerPostLike.count({
where: { beerPostId },
});
return count;
};
const getBeerPostLikeCount = async ({ beerPostId }: { beerPostId: string }) =>
DBClient.instance.beerPostLike.count({ where: { beerPostId } });
export default getBeerPostLikeCount;

View File

@@ -1,11 +1,10 @@
import DBClient from '@/prisma/DBClient';
const removeBeerPostLikeById = async (id: string) => {
return DBClient.instance.beerPostLike.delete({
where: {
id,
},
});
};
interface RemoveBeerPostLikeArgs {
beerLikeId: string;
}
const removeBeerPostLikeById = async ({ beerLikeId }: RemoveBeerPostLikeArgs) =>
DBClient.instance.beerPostLike.delete({ where: { id: beerLikeId } });
export default removeBeerPostLikeById;