auth-service/src/modules/auth/auth.repository.ts

37 lines
936 B
TypeScript

import { Injectable } from '@nestjs/common'
import { Account } from '@prisma/generated/client'
import {
AccountCreateInput,
AccountUpdateInput
} from '@prisma/generated/models/Account'
import { PrismaService } from '@/infra/prisma/prisma.service'
@Injectable()
export class AuthRepository {
public constructor(private readonly prismaService: PrismaService) {}
public findByPhone(phone: NonNullable<Account['phone']>) {
return this.prismaService.account.findUnique({
where: { phone }
})
}
public findByEmail(email: NonNullable<Account['email']>) {
return this.prismaService.account.findUnique({
where: { email }
})
}
public createAccount(data: AccountCreateInput) {
return this.prismaService.account.create({ data })
}
public updateAccount(id: Account['id'], data: AccountUpdateInput) {
return this.prismaService.account.update({
where: { id },
data
})
}
}