Creating a primary column

Each entity must have at least one primary key column.This is a requirement and you can’t avoid it.To make a column a primary key, you need to use @PrimaryColumn decorator.

  1. import {Entity, Column, PrimaryColumn} from "typeorm";
  2. @Entity()
  3. export class Photo {
  4. @PrimaryColumn()
  5. id: number;
  6. @Column()
  7. name: string;
  8. @Column()
  9. description: string;
  10. @Column()
  11. filename: string;
  12. @Column()
  13. views: number;
  14. @Column()
  15. isPublished: boolean;
  16. }