Search code examples
javascriptnode.jspostgresqltypescripttypeorm

TypeORM array is not supported in postgres?


I have a column kid_ages which is Integer[]. When migrating, I get the following error:

DataTypeNotSupportedError: Data type "Array" in "home.kid_ages" is not supported by "postgres" database.

I tried adding the following options to my column:

type: 'array'

and:

array: true,
default: [],
nullable: false,

like this:

@Column({
  array: true,
  default: [],
  nullable: false,
})
kid_ages: string;

Solution

  • The docs says, that it should work:

    @Column("int", { array: true })
    array: number[];
    

    this is from the example https://github.com/typeorm/typeorm/blob/master/test/functional/database-schema/column-types/postgres/entity/Post.ts

    In your code the array property is no array. Have you tried kid_ages: string[];?