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.
14 lines
480 B
14 lines
480 B
import { EntityRepository, Repository } from 'typeorm';
|
|
import { Role } from './roles.entity';
|
|
import { Optional } from 'typescript-optional';
|
|
|
|
@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, {}));
|
|
}
|
|
}
|