import { Column , Entity , OneToMany , PrimaryGeneratedColumn } from 'typeorm' ; import { Post } from './post.entity' ; @ Entity ( 'user' ) export class User { @ PrimaryGeneratedColumn ( ) id : number ; @ Column ( { unique : true } ) name : string ; @ OneToMany ( type => Post , post => post . user , { cascade : [ 'insert' ] } ) posts : Post [ ] ; }