added character stuff

This commit is contained in:
2024-05-11 18:58:43 +02:00
parent ebfbae864b
commit b3a2d8bfaa
13 changed files with 45 additions and 17 deletions

View File

@ -0,0 +1,20 @@
import prisma from '../utilities/prisma'; // Import the global Prisma instance
import {Character} from '@prisma/client';
import CharacterService from "../services/character.service";
class CharacterRepository {
async getByUserId(userId: number): Promise<Character[] | null> {
try {
return await prisma.character.findMany({
where: {
userId,
},
});
} catch (error: any) {
// Handle error
throw new Error(`Failed to get character by user ID: ${error.message}`);
}
}
}
export default new CharacterService;