mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-17 03:05:13 +00:00
Add Unique constraint to user and roleType fields in UserRoleEntity
This commit is contained in:
@ -1,10 +1,11 @@
|
||||
import { Entity, ManyToOne } from 'typeorm';
|
||||
import { Entity, ManyToOne, Unique } from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { UserRoleDto } from '../dtos';
|
||||
import { UserEntity } from '../../user/entities';
|
||||
import { RoleTypeEntity } from '../../role-type/entities';
|
||||
|
||||
@Entity({ name: 'user-role' })
|
||||
@Unique(['user', 'roleType'])
|
||||
export class UserRoleEntity extends AbstractEntity<UserRoleDto> {
|
||||
@ManyToOne(() => UserEntity, (user) => user.role, {
|
||||
nullable: false,
|
||||
|
Reference in New Issue
Block a user