20 lines
579 B
TypeScript
Executable File
20 lines
579 B
TypeScript
Executable File
import { Entity, Property, Unique, ManyToMany, Collection, PrimaryKey } from '@mikro-orm/core';
|
|
import { BaseEntity } from '../../../common/entities/base.entity';
|
|
import { Role } from './role.entity';
|
|
import { ulid } from 'ulid';
|
|
|
|
@Entity({ tableName: 'permissions' })
|
|
export class Permission extends BaseEntity {
|
|
@PrimaryKey({ type: 'string', columnType: 'char(26)' })
|
|
id: string = ulid()
|
|
|
|
@Property({ unique: true })
|
|
name!: string;
|
|
|
|
@Property()
|
|
title!: string;
|
|
|
|
@ManyToMany({ entity: () => Role, mappedBy: 'permissions' })
|
|
roles = new Collection<Role>(this);
|
|
}
|