adding the plan post api

This commit is contained in:
Md Sharafat Hassain
2026-04-07 22:32:13 +06:00
parent ba1b0df589
commit bcdb125af1
12 changed files with 345 additions and 1 deletions
+45
View File
@@ -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,
};