59 lines
1.2 KiB
TypeScript
59 lines
1.2 KiB
TypeScript
// src/app/services/AppLog.service.ts
|
|
//
|
|
// REQ0047/T.B.A.
|
|
//
|
|
// PURPOSE:
|
|
// - AppLog example for handling AppLog Record
|
|
//
|
|
// RULES:
|
|
// - T.B.A.
|
|
//
|
|
|
|
import type { AppLog } from '@prisma/client';
|
|
|
|
import prisma from '../lib/prisma';
|
|
|
|
type CreateAppLog = {
|
|
level: number;
|
|
message: string;
|
|
metadata: Record<string, any>;
|
|
};
|
|
|
|
// type UpdateAppLog = {
|
|
// level: number;
|
|
// message: string;
|
|
// };
|
|
|
|
async function listAppLogs(): Promise<AppLog[]> {
|
|
return prisma.appLog.findMany();
|
|
}
|
|
|
|
async function getAppLog(appLogId: string) {
|
|
return prisma.appLog.findFirst({ where: { id: appLogId } });
|
|
}
|
|
|
|
async function createAppLog(level: number, message: string, metadata: Record<string, any>) {
|
|
return prisma.appLog.create({ data: { level, message, metadata } });
|
|
}
|
|
|
|
async function createNewAppLog(createForm: CreateAppLog) {
|
|
return prisma.appLog.create({ data: createForm });
|
|
}
|
|
|
|
// async function updateAppLog(appLogId: string, updateForm: UpdateAppLog) {
|
|
// return prisma.appLog.update({ where: { id: appLogId }, data: updateForm });
|
|
// }
|
|
|
|
async function deleteAppLog(appLogId: string) {
|
|
return prisma.appLog.delete({ where: { id: appLogId } });
|
|
}
|
|
|
|
export {
|
|
getAppLog,
|
|
listAppLogs,
|
|
// updateAppLog,
|
|
deleteAppLog,
|
|
createAppLog,
|
|
createNewAppLog,
|
|
};
|