Template API: create database schema

This commit is contained in:
2026-04-27 00:03:06 +06:00
parent 61fd639faf
commit 47d30d96eb
9 changed files with 599 additions and 0 deletions
@@ -0,0 +1,46 @@
import { Request } from "express";
import { prisma } from "../../lib/prisma.js";
const get_all_template_from_db = async (req: Request) => {
// define your own login here
const result = await prisma.template.findMany();
return result;
};
const get_single_template_from_db = async (req: Request) => {
// define your own login here
const { id } = req.params;
const result = await prisma.template.findUnique({ where: { id } });
return result;
};
const create_template_into_db = async (req: Request) => {
// define your own login here
const result = await prisma.template.create({ data: req.body });
return result;
};
const update_template_into_db = async (req: Request) => {
// define your own login here
const { id } = req.params;
const result = await prisma.template.update({
where: { id },
data: req.body,
});
return result;
};
const delete_template_from_db = async (req: Request) => {
// define your own login here
const { id } = req.params;
const result = await prisma.template.delete({ where: { id } });
return result;
};
export const template_service = {
get_all_template_from_db,
get_single_template_from_db,
create_template_into_db,
update_template_into_db,
delete_template_from_db,
};