Column data types
Next, let’s fix our data types. By default, string is mapped to a varchar(255)-like type (depending on the database type).Number is mapped to a integer-like type (depending on the database type).We don’t want all our columns to be limited varchars or integers.Let’s setup correct data types:
import {Entity, Column, PrimaryGeneratedColumn} from "typeorm";
@Entity()
export class Photo {
@PrimaryGeneratedColumn()
id: number;
@Column({
length: 100
})
name: string;
@Column("text")
description: string;
@Column()
filename: string;
@Column("double")
views: number;
@Column()
isPublished: boolean;
}
Column types are database-specific.You can set any column type your database supports.More information on supported column types can be found here.