import { Users } from "src/entity/user.entity";
import { Injectable } from "@nestjs/common";
import { InjectRepository } from "@nestjs/typeorm";
import { FindOneOptions, Repository } from "typeorm";

@Injectable()
export class UserService {
    constructor(
        @InjectRepository(Users)
        private userRepository: Repository<Users>) { }

    async findAll(): Promise<Users[]> {
        return await this.userRepository.find();
    }

    async findOne(id: number): Promise<Users> {
        return await this.userRepository.findOne(id)
    }

    async remove(id: number): Promise<void> {
        await this.userRepository.delete(id)
    }

    async save(user: Users): Promise<Users> {
        return await this.userRepository.save(user)
    }

    async update(id: number, user: Users): Promise<void> {
        await this.userRepository.update(id, user);
    }
}