mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-08-25 05:42:27 +00:00
34 lines
910 B
TypeScript
34 lines
910 B
TypeScript
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({
|
|
...data,
|
|
}),
|
|
);
|
|
}
|
|
|
|
findOne(where: FindOptionsWhere<User> | FindOptionsWhere<User>[]) {
|
|
return this.userRepository.findOne({ where, relations: ['profilePicture'] });
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|