Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. export abstract class Content {
  2.  
  3. @PrimaryGeneratedColumn()
  4. id: number;
  5.  
  6. @Column()
  7. title: string;
  8.  
  9. @Column()
  10. description: string;
  11.  
  12. }
  13. @Entity()
  14. export class Photo extends Content {
  15.  
  16. @Column()
  17. size: string;
  18.  
  19. }
  20. @Entity()
  21. export class Question extends Content {
  22.  
  23. @Column()
  24. answersCount: number;
  25.  
  26. }
  27. @Entity()
  28. export class Post extends Content {
  29.  
  30. @Column()
  31. viewCount: number;
  32.  
  33. }
  34.  
  35. export abstract class Content {
  36.  
  37. @PrimaryGeneratedColumn()
  38. id: number;
  39.  
  40. @Column()
  41. title: string;
  42.  
  43. @Column()
  44. description: string;
  45.  
  46. // WOULD LIKE TO ADD SOMETHING LIKE THIS ...
  47. @ManyToOne(() => User, user => user.createdContent)
  48. createdBy: User
  49.  
  50. }
  51.  
  52.  
  53. @Entity()
  54. export default class User {
  55.  
  56. // AND THIS ...
  57. @OneToMany(() => Content, content => content.authoredBy)
  58. authoredContent: Content[]
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement