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:

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

Column types are database-specific.You can set any column type your database supports.More information on supported column types can be found here.