Created
May 30, 2020 22:17
-
-
Save vinipachecov/8bcad0e802b8f190346471d811845eb2 to your computer and use it in GitHub Desktop.
Posts file for React-Native typeorm setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
Entity, | |
PrimaryGeneratedColumn, | |
Column, | |
ManyToMany, | |
JoinTable, | |
ManyToOne, | |
} from 'typeorm/browser'; | |
import { Category } from './category'; | |
import { Author } from './author'; | |
@Entity('post') | |
export class Post { | |
@PrimaryGeneratedColumn() | |
id: number; | |
@Column() | |
title: string; | |
@Column('text') | |
text: string; | |
@ManyToMany((type) => Category, { | |
cascade: ['insert'], | |
}) | |
@JoinTable() | |
categories: Category[]; | |
@ManyToOne((type) => Author, (author) => author.posts, { | |
cascade: ['insert'], | |
}) | |
author: Author; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment