update users set relation many to many and it's related changed roles

This commit is contained in:
2025-01-10 19:30:58 +07:00
parent cb4cb7c5ee
commit 749cae8820
2 changed files with 9 additions and 10 deletions

View File

@ -1,5 +1,5 @@
import bcrypt from 'bcryptjs';
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index, OneToOne, JoinColumn, ManyToOne } from 'typeorm';
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index, OneToOne, JoinColumn, ManyToOne, OneToMany, ManyToMany, JoinTable } from 'typeorm';
import { Status } from '../types/status';
import { UserRole } from './users_roles';
@ -11,7 +11,7 @@ export class User {
@Column({
nullable: false,
unique: true,
unique: false,
length: 64
})
email: string;
@ -25,7 +25,7 @@ export class User {
@Column({
nullable: false,
unique: true,
unique: false,
length: 64
})
username: string;
@ -33,15 +33,13 @@ export class User {
@Column({
nullable: true,
length: 64,
unique: true,
unique: false,
})
name: string;
@Column({
nullable: true,
type: 'uuid'
})
id_role: string;
@ManyToMany(() => UserRole, { onDelete: 'CASCADE' })
@JoinTable()
roles: UserRole[]
@Index()
@Column({

View File

@ -1,7 +1,8 @@
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, JoinColumn, ManyToOne } from 'typeorm';
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, JoinColumn, ManyToOne, ManyToMany } from 'typeorm';
import { Status } from '../types/status';
import { Application } from './application';
import { User } from './users';
@Entity('user_roles')
export class UserRole {