Skip to content

Commit

Permalink
Add relation to examples
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel7grant committed Nov 3, 2024
1 parent 2e0943f commit 2308791
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
19 changes: 17 additions & 2 deletions examples/legacy/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
import { Entity, Column } from 'typeorm';
import { Entity, Column, OneToMany, PrimaryGeneratedColumn } from 'typeorm';

@Entity({ name: 'User' })
@Entity()
export class Post {
@PrimaryGeneratedColumn()
id: number;

@Column({ type: 'number' })
userId: number;
}

@Entity()
export class User {
@PrimaryGeneratedColumn()
id: number;

@Column({ type: 'string' })
name: number;

@OneToMany(() => Post, (post) => post.userId)
posts: Post;
}
19 changes: 17 additions & 2 deletions examples/recommended/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
import { Entity, Column } from 'typeorm';
import { Entity, Column, OneToMany, PrimaryGeneratedColumn } from 'typeorm';

@Entity({ name: 'User' })
@Entity()
export class Post {
@PrimaryGeneratedColumn()
id: number;

@Column({ type: 'number' })
userId: number;
}

@Entity()
export class User {
@PrimaryGeneratedColumn()
id: number;

@Column({ type: 'string' })
name: number;

@OneToMany(() => Post, (post) => post.userId)
posts: Post;
}

0 comments on commit 2308791

Please sign in to comment.