import { Column , Entity , JoinColumn , ManyToOne , OneToMany } from 'typeorm' ; import { AbstractEntity } from '../../common/abstract.entity' ; import { UseDto } from '../../decorators' ; import { UserEntity } from '../user/user.entity' ; import { PostDto } from './dtos/post.dto' ; import { PostTranslationEntity } from './post-translation.entity' ; @ Entity ( { name : 'posts' } ) @ UseDto ( PostDto ) export class PostEntity extends AbstractEntity < PostDto > { @ Column ( { type : 'uuid' } ) userId : Uuid ; @ ManyToOne ( ( ) => UserEntity , ( userEntity ) => userEntity . posts , { onDelete : 'CASCADE' , onUpdate : 'CASCADE' , } ) @ JoinColumn ( { name : 'user_id' } ) user : UserEntity ; @ OneToMany ( ( ) => PostTranslationEntity , ( questionTranslationEntity ) => questionTranslationEntity . post ) translations : PostTranslationEntity [ ] ; }