import { EntityRepository } from '@mikro-orm/core';
import { User } from '@/apps/_app/entities/user/_User';

export class UserRepository extends EntityRepository<User> {
    async findAllUsers(): Promise<User[]> {
        return this.findAll({
            populate: ['roles'],
        });
    }

    async findUserById(id: number): Promise<User | null> {
        return this.findOne({ id }, { populate: ['roles'] });
    }

    async findUserByUsername(username: string): Promise<User | null> {
        return this.findOne({ username }, { populate: ['roles'] });
    }
}
