https://github.com/typeorm/typeorm/issues/3657
import { Entity, PrimaryColumn, Column, ManyToOne, JoinColumn, Index } from "typeorm";
import { Role } from './Role';
import { Permission } from './Permission';
@Entity()
export class RolePermission {
@PrimaryColumn({ name: 'role_id' })
roleId?: number;
@PrimaryColumn({ name: 'permission_id' })
permissionId?: number;
@ManyToOne(type => Role, role => role.rolePermissions)
@JoinColumn({ name: "role_id", referencedColumnName: "id" })
role: Role;
@ManyToOne(type => Permission, Permission => Permission.rolePermissions)
@JoinColumn({ name: "permission_id", referencedColumnName: "id" })
permission: Permission;
}
网友评论