added character stuff
This commit is contained in:
20
src/app/repositories/character.repository.ts
Normal file
20
src/app/repositories/character.repository.ts
Normal 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;
|
Reference in New Issue
Block a user