mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 18:52:06 +00:00
Refactor codebase, format
This commit is contained in:
20
services/BeerPostLike/createBeerPostLike.ts
Normal file
20
services/BeerPostLike/createBeerPostLike.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import DBClient from '@/prisma/DBClient';
|
||||
import { z } from 'zod';
|
||||
import GetUserSchema from '../User/schema/GetUserSchema';
|
||||
|
||||
const createBeerPostLike = async ({
|
||||
id,
|
||||
user,
|
||||
}: {
|
||||
id: string;
|
||||
user: z.infer<typeof GetUserSchema>;
|
||||
}) => {
|
||||
return DBClient.instance.beerPostLike.create({
|
||||
data: {
|
||||
beerPost: { connect: { id } },
|
||||
user: { connect: { id: user.id } },
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export default createBeerPostLike;
|
||||
6
services/BeerPostLike/findBeerPostLikeById.ts
Normal file
6
services/BeerPostLike/findBeerPostLikeById.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import DBClient from '@/prisma/DBClient';
|
||||
|
||||
const findBeerPostLikeById = async (id: string) =>
|
||||
DBClient.instance.beerPostLike.findUnique({ where: { id } });
|
||||
|
||||
export default findBeerPostLikeById;
|
||||
11
services/BeerPostLike/removeBeerPostLikeById.ts
Normal file
11
services/BeerPostLike/removeBeerPostLikeById.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import DBClient from '@/prisma/DBClient';
|
||||
|
||||
const removeBeerPostLikeById = async (id: string) => {
|
||||
return DBClient.instance.beerPostLike.delete({
|
||||
where: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export default removeBeerPostLikeById;
|
||||
Reference in New Issue
Block a user