TypeORM array is not supported in postgres? TypeORM array is not supported in postgres? typescript typescript

TypeORM array is not supported in postgres?


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[];?


As mentioned above, you can create Postgres' array column with next code:

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

If you then need to find some kid with age 5, use this:

kid = getRepository('kid')        .createQueryBuilder()        .where(':kid_age = ANY (kid.kid_ages)', { kid_age: 5 });


For people looking to deal with arrays or string within your entities, based on @thopaw 's answer, you can use the following code:

@Column("text", { array: true })kid_ages: string[];