I'm trying to set up a simple one-to-one relation between an item and item_name. The entity looks as follows:
@Entity('item')
export class ItemEntity {
@PrimaryColumn('integer')
id: number;
@OneToOne(() => ItemNameEntity)
@JoinColumn()
name: ItemNameEntity;
// ... other props
}
item-name.entity
@Entity('item_name')
export class ItemNameEntity {
@PrimaryGeneratedColumn()
id: number;
@Column()
en: string;
@Column()
fr: string;
// ... other properties
}
I insert an item using the following payload:
{
id: 26,
name: { en: 'English name', fr: 'French name' },
}
It stores the item as expected, and adds a nameId column. The problem is that it does not insert anything into item_name, and thus the nameId column is null.
What am I missing here?