Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 303
dealwap Avatar asked Oct 23 '25 15:10

dealwap


2 Answers

I was able to resolve this with

  @Column('simple-array', { nullable: true, array: true })
  city: string[];
like image 72
dealwap Avatar answered Oct 26 '25 05:10

dealwap


This should work for an array.

@Column('text', { array: true })
names: string[];
like image 36
Onesmus Muna Avatar answered Oct 26 '25 05:10

Onesmus Muna



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!