architecture refactoring
This commit is contained in:
45
backend/src/data/repositories/auth.repository.impl.ts
Normal file
45
backend/src/data/repositories/auth.repository.impl.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* auth.repository.impl.ts
|
||||
* AuthRepositoryImpl: implementación real del AuthRepository.
|
||||
* Aquí es donde hablamos con la base de datos usando Prisma.
|
||||
*/
|
||||
|
||||
import { AuthRepository } from "../../domain/repositories/auth.repository.js";
|
||||
import { prisma } from "../postgres/index.js";
|
||||
|
||||
export class AuthRepositoryImpl implements AuthRepository {
|
||||
async findByEmail(email: string) {
|
||||
return prisma.user.findUnique({
|
||||
where: { email },
|
||||
select: {
|
||||
id: true,
|
||||
email: true,
|
||||
password: true,
|
||||
name: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async create(data: { name: string; email: string; password: string }) {
|
||||
return prisma.user.create({
|
||||
data,
|
||||
select: {
|
||||
id: true,
|
||||
email: true,
|
||||
name: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async findById(id: number) {
|
||||
return prisma.user.findUnique({
|
||||
where: { id },
|
||||
select: {
|
||||
id: true,
|
||||
email: true,
|
||||
name: true,
|
||||
role: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user