属性在持久化的TypeORM实体中仅包含ID,而不包含整个实体

时间:2020-11-12 14:51:40

标签: node.js typescript orm nestjs typeorm

我有这个实体类:

@Entity("organization")
export class OrganizationEntity {

    // ...

    @PrimaryColumn({name: "party_id"})
    @OneToOne(() => PartyEntity, {cascade: true})
    @JoinColumn({name: "party_id", referencedColumnName: "id"})
    party: PartyEntity

}

然后我创建一个新的OrganizationEntity并坚持下去:

const savedOrganizationEntity = await this.organizationTypeOrmRepository.save(organizationEntity);
// see Repository.save

但是,返回的savedOrganizationEntity在现场聚会中包含一个字符串,而不是PartyEntity对象。

如何解决此问题,以便OrganizationEntity.party包含PartyEntity,而不是字符串?

1 个答案:

答案 0 :(得分:0)

该行为按设计的方式进行:https://github.com/typeorm/typeorm/issues/3490