code update

This commit is contained in:
2024-05-09 22:03:21 +02:00
parent 8356a83431
commit a2f21229d8
14 changed files with 216 additions and 45 deletions

View File

@ -1,15 +0,0 @@
import { Map } from '@prisma/client';
import prisma from '../utilities/prisma'; // Import the global Prisma instance
class MapRepository {
async getFirst(): Promise<Map | null> {
try {
return await prisma.map.findFirst();
} catch (error: any) {
// Handle error
throw new Error(`Failed to get first map: ${error.message}`);
}
}
}
export default MapRepository;

View File

@ -0,0 +1,24 @@
import { Zone } from '@prisma/client';
import prisma from '../utilities/prisma'; // Import the global Prisma instance
class ZoneRepository {
async getFirst(): Promise<Zone | null> {
try {
return await prisma.zone.findFirst();
} catch (error: any) {
// Handle error
throw new Error(`Failed to get first zone: ${error.message}`);
}
}
async getAll(): Promise<Zone[]> {
try {
return await prisma.zone.findMany();
} catch (error: any) {
// Handle error
throw new Error(`Failed to get all zone: ${error.message}`);
}
}
}
export default ZoneRepository;