I am defining entity fields in my NestJS project. I have ManyToOne realtion that is defined successfully. I have trouble finding the right way to define OneToMany relation to fit the syntax I used for other relation.
import {Entity,Column, PrimaryColumn, ManyToOne,JoinColumn,OneToMany} from "typeorm";
import { Account } from "./account.entity";
import { Balance } from "./balance.entity";
import { BaseEntity } from "./base.entity";
@Entity()
export class MainEntity extends BaseEntity {
@PrimaryColumn({
type: "varchar",
name: "id",
unique: true
})
id: string;
@ManyToOne(() => Account, { nullable: true })
@JoinColumn({
name: "account_id",
referencedColumnName: "id"
})
account: Account;
@OneToMay relation needs to be connected to the Balance entity and mappedBy paymentDevice field in it.
My try:
@OneToMany(() => Balance, ...)
balances: Balance[]
I am in NestJs and typescript so this is challenging for me.