Create an entity
Entity is your model decorated by an @Entity
decorator.A database table will be created for such models.You work with entities everywhere with TypeORM.You can load/insert/update/remove and perform other operations with them.
Let’s make our Photo
model as an entity:
import {Entity} from "typeorm";
@Entity()
export class Photo {
id: number;
name: string;
description: string;
filename: string;
views: number;
isPublished: boolean;
}
Now, a database table will be created for the Photo
entity and we’ll be able to work with it anywhere in our app.We have created a database table, however what table can exist without columns?Let’s create a few columns in our database table.