Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Relation
import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm';
import { User } from './user.entity';
@Entity()
export class Role {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({
unique: true,
})
name: string;
}
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
ManyToMany,
JoinTable,
} from 'typeorm';
import { Role } from './role.entity';
@Entity()
export class User {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column()
name: string;
@Column({
unique: true,
})
email: string;
@Column()
password: string;
@CreateDateColumn()
insertedAt: Date;
@UpdateDateColumn()
updatedAt: Date;
@ManyToMany(type => Role)
@JoinTable()
roles: Role[];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.