Yield generated for b918be50-5f99-429b-b6eb-86844005f128
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

15 lines
535 B

import { EntityRepository, Repository } from 'typeorm';
import { Role } from './roles.entity';
import Optional from 'typescript-optional';
import { ADMIN_ROLE, USER_ROLE } from './roles.constants';
@EntityRepository(Role)
export class RolesRepository extends Repository<Role> {
async findRoleByName(name: string): Promise<Optional<Role>> {
return Optional.ofNullable(await this.findOne({ name }));
}
async findOneById(id: number): Promise<Optional<Role>> {
return Optional.ofNullable(await this.findOne(id, {}));
}
}