Kononnable / typeorm-model-generator

Generates models for TypeORM from existing database.
MIT License
1.51k stars 281 forks source link

When typeorm-model-generator decided to add number to fieldName? #319

Closed wizardnet972 closed 3 years ago

wizardnet972 commented 3 years ago

Why when I run typeorm-model-generator I get 2 added to the field name?

When I debug the source code I log the databaseModel:

In the picture you can see the relations have fieldName with value: companyCd2, it should be companies.

So my question is in which cases it adds a number to the field name?

image

luiys commented 2 years ago

how to solve this?

I'm having the following problem:

@Column("int", { name: "grupo", nullable: true })
 group: number | null; 

@ManyToOne(() => GrupoAcesso, (grupoAcesso) => grupoAcesso.grupoAcessoMenus, {
    onDelete: "NO ACTION",
    onUpdate: "NO ACTION",
})
@JoinColumn([{ name: "grupo", referencedColumnName: "id" }])
group2: GrupoAcesso;

I just need the relation to be generated

typeorm-model-generator version: 0.4.6 database: mysql