Generated columns with Typorm in PostgreSQL

Issue

I want to generate a column with typeorm but it’s not working,
I am using PostgreSQL and I followed this article, it’s said that is supported by typeorm
https://wanago.io/2021/11/29/generated-columns-postgresql-typeorm/

this is an example:

import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
 
@Entity()
class User {
  @PrimaryGeneratedColumn()
  public id: number;
 
  @Column()
  public firstName: string;
 
  @Column()
  public lastName: string;
 
  @Column({
    generatedType: 'STORED',
    asExpression: `'firstName' || ' ' || 'lastName'`
  })
  fullName: string;
}

any idea how to do it ?

Solution

I found I was using an old version of Typeorm (@0.2.28) and the feature was supported in postgres in the version @0.2.42

Answered By – GisCat

Answer Checked By – Marilyn (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.