i can’t insert related table fields

I leave the way I fix it, in case it helps someone in the future.

In personas changed:

@OneToMany(() => Contacto, (contacto) => contacto.idpersona, {
cascade: ['insert']
public contactos: Contacto[]`


@OneToMany(type => Contactos, contactos => contactos.personas,{
cascade : true,
public contactos: Contactos[];`

In contactos changed:

idpersona: number;
@ManyToOne(type => Personas, {
@JoinColumn({name: "idpersona"})
persona: string;`


@ManyToOne(() => Personas, personas => personas.id, {nullable: false})
@JoinColumn({name: "idpersona"})
personas: Personas;

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top