my 13th reason
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import prisma from '../utilities/prisma'; // Import the global Prisma instance
|
||||
import prisma from '../utilities/Prisma'; // Import the global Prisma instance
|
||||
import {Character} from '@prisma/client';
|
||||
import CharacterService from "../services/character.service";
|
||||
import CharacterService from "../services/CharacterService";
|
||||
|
||||
class CharacterRepository {
|
||||
async getByUserId(userId: number): Promise<Character[] | null> {
|
@ -1,7 +1,19 @@
|
||||
import prisma from '../utilities/prisma'; // Import the global Prisma instance
|
||||
import prisma from '../utilities/Prisma'; // Import the global Prisma instance
|
||||
import { User } from '@prisma/client';
|
||||
|
||||
class UserRepository {
|
||||
async getById(id: number): Promise<User | null> {
|
||||
try {
|
||||
return await prisma.user.findUnique({
|
||||
where: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
} catch (error: any) {
|
||||
// Handle error
|
||||
throw new Error(`Failed to get user by ID: ${error.message}`);
|
||||
}
|
||||
}
|
||||
async getByUsername(username: string): Promise<User | null> {
|
||||
try {
|
||||
return await prisma.user.findUnique({
|
||||
@ -14,7 +26,6 @@ class UserRepository {
|
||||
throw new Error(`Failed to get user by username: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
async create(username: string, password: string): Promise<User> {
|
||||
try {
|
||||
return await prisma.user.create({
|
@ -1,5 +1,5 @@
|
||||
import { Zone } from '@prisma/client';
|
||||
import prisma from '../utilities/prisma'; // Import the global Prisma instance
|
||||
import prisma from '../utilities/Prisma'; // Import the global Prisma instance
|
||||
|
||||
class ZoneRepository {
|
||||
async getFirst(): Promise<Zone | null> {
|
Reference in New Issue
Block a user