role module

This commit is contained in:
2026-01-13 23:28:33 +03:30
parent d630cb844a
commit d046dc21ac
17 changed files with 171 additions and 442 deletions
@@ -1,17 +1,19 @@
import { Entity, Property, Unique, ManyToMany, Collection } from '@mikro-orm/core';
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 {
@Property()
@Unique()
@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);
}