G
G
Golopolos2022-04-18 19:02:22
ORM
Golopolos, 2022-04-18 19:02:22

How to add a helper method to TypeORM?

Tell me how to correctly specify the methods

import { Column, Entity } from "typeorm";

@Entity("users")
export class User extends Template {

@Column({ name: 'firstname', nullable: true })
  firstName: string

  @Column({ name: 'lastname', nullable: true })
  lastName: string

  public get fullName(): string {
    return `${this.firstName} ${this.lastName}`
  }
}

When accessing {users.fullName}, an empty field!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question