Create a model

Working with a database starts from creating tables.How do you tell TypeORM to create a database table?The answer is - through the models.Your models in your app are your database tables.

For example, you have a Photo model:

  1. export class Photo {
  2. id: number;
  3. name: string;
  4. description: string;
  5. filename: string;
  6. views: number;
  7. isPublished: boolean;
  8. }

And you want to store photos in your database.To store things in the database, first you need a database table,and database tables are created from your models.Not all models, but only those you define as entities.