mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-08-25 13:49:40 +00:00
refactor: sepeare user and auth modules
This commit is contained in:
35
src/user/repositories/user.repository.ts
Normal file
35
src/user/repositories/user.repository.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { FindOptionsWhere, Repository } from 'typeorm';
|
||||
import { User } from '../../user/entities';
|
||||
|
||||
@Injectable()
|
||||
export class UserRepository {
|
||||
constructor(@InjectRepository(User) private readonly userRepository: Repository<User>) {}
|
||||
|
||||
createUnverifiedUser(data: Partial<User>) {
|
||||
return this.userRepository.save(
|
||||
this.userRepository.create({
|
||||
phoneNumber: data.phoneNumber,
|
||||
countryCode: data.countryCode,
|
||||
roles: data.roles,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
findOne(where: FindOptionsWhere<User> | FindOptionsWhere<User>[]) {
|
||||
return this.userRepository.findOne({ where });
|
||||
}
|
||||
|
||||
update(userId: string, data: Partial<User>) {
|
||||
return this.userRepository.update(userId, data);
|
||||
}
|
||||
|
||||
createUser(data: Partial<User>) {
|
||||
const user = this.userRepository.create({
|
||||
...data,
|
||||
});
|
||||
|
||||
return this.userRepository.save(user);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user