Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set column length to "max" in typeorm postgresql?

I am new to typeorm. I want to set the length of a column to "MAX".

Here is what I've tried:

@Entity('InboundCallConfig')
export class InboundCallConfigEntity{
    @Index()
    @PrimaryGeneratedColumn()
    Id: number;

    @Column( { nullable: true , length: 200 })
    CallerId: string;

    @Column( { type: "varchar", length:"MAX" } )
    WebhookUrl :string;

    @Column( { type:"varchar", length: 100, nullable:true})
    HTTPMethod: string;

    @Column( {default: false} )
    IsDeleted: boolean;
}

but when I try to run my program it got an error saying :

enter image description here

Thanks in advance!

like image 562
venalyn sudaria Avatar asked Sep 08 '25 05:09

venalyn sudaria


1 Answers

Based on the documentation of typeorm it only accepts number type value for length property :

@Column({
    type: "varchar",
    length: 150,
    unique: true,
    // ...
})
name: string;

length: number - Column type's length. For example if you want to create varchar(150) type you specify column type and length options.

Also mysql server version is important because some versions don't support MAX syntax on length property and some has restrictions on string byte size of a column .

like image 127
Mahdi Faraji Avatar answered Sep 10 '25 00:09

Mahdi Faraji