adding the plan post api
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
|
||||
import { Request } from "express";
|
||||
import { prisma } from "../../lib/prisma";
|
||||
|
||||
const get_all_plan_from_db = async (req: Request) => {
|
||||
// define your own login here
|
||||
const result = await prisma.plan.findMany();
|
||||
return result;
|
||||
};
|
||||
|
||||
const get_single_plan_from_db = async (req: Request) => {
|
||||
// define your own login here
|
||||
const { id } = req.params ;
|
||||
const result = await prisma.plan.findUnique({ where: { id } });
|
||||
return result;
|
||||
};
|
||||
|
||||
const create_plan_into_db = async (req: Request) => {
|
||||
// define your own login here
|
||||
console.log(req.body)
|
||||
const result = await prisma.plan.create({ data: req.body });
|
||||
return result;
|
||||
};
|
||||
|
||||
const update_plan_into_db = async (req: Request) => {
|
||||
// define your own login here
|
||||
const { id } = req.params;
|
||||
const result = await prisma.plan.update({ where: { id }, data: req.body });
|
||||
return result;
|
||||
};
|
||||
|
||||
const delete_plan_from_db = async (req: Request) => {
|
||||
// define your own login here
|
||||
const { id } = req.params;
|
||||
const result = await prisma.plan.delete({ where: { id } });
|
||||
return result;
|
||||
};
|
||||
|
||||
export const plan_service = {
|
||||
get_all_plan_from_db,
|
||||
get_single_plan_from_db,
|
||||
create_plan_into_db,
|
||||
update_plan_into_db,
|
||||
delete_plan_from_db,
|
||||
};
|
||||
Reference in New Issue
Block a user