dealwap
dealwap

Reputation: 721

Store array of string in typeorm postgres database

I would like to store an array of strings in my Postgres database, I have the below code but it is not working as I want:

  @Column({type: 'text', array: true, nullable: true })
  names: string[] = [];

I got the following error:

PostgreSQL said: malformed array literal: "["james"]"
Detail: "[" must introduce explicitly-specified array dimensions.

Anything I might be doing wrong?

Upvotes: 4

Views: 14959

Answers (2)

dealwap
dealwap

Reputation: 721

I was able to resolve this with

  @Column('simple-array', { nullable: true, array: true })
  city: string[];

Upvotes: 14

Onesmus Muna
Onesmus Muna

Reputation: 461

This should work for an array.

@Column('text', { array: true })
names: string[];

Upvotes: 3

Related Questions