Files
HKSingleParty/03_source/cms_backend/src/app/services/helloworld.service.ts

45 lines
1.1 KiB
TypeScript

// src/app/services/helloworld.service.ts
//
// REQ0047/T.B.A.
//
// PURPOSE:
// - helloworld example for handling helloworld Record
//
// RULES:
// - T.B.A.
//
import type { Helloworld } from '@prisma/client';
import prisma from '../lib/prisma';
type CreateHelloworld = {
hello: string;
};
type UpdateHelloworld = {
hello: string;
};
async function listHelloworlds(): Promise<Helloworld[]> {
return prisma.helloworld.findMany();
}
async function getHelloworld(helloworldId: number) {
return prisma.helloworld.findFirst({ where: { id: helloworldId } });
}
async function createNewHelloworld(createForm: CreateHelloworld) {
return prisma.helloworld.create({ data: createForm });
}
async function updateHelloworld(helloworldId: number, updateForm: UpdateHelloworld) {
return prisma.helloworld.update({ where: { id: helloworldId }, data: updateForm });
}
async function deleteHelloworld(helloworldId: number) {
return prisma.helloworld.delete({ where: { id: helloworldId } });
}
export { getHelloworld, listHelloworlds, updateHelloworld, deleteHelloworld, createNewHelloworld };