I have the following entities:
@Entity({ name: 'user' })
export class UserEntity extends BasicEntity {
@PrimaryGeneratedColumn()
id: number;
@Column({
nullable: false,
unique: true,
})
login: string;
}
@Entity({ name: 'wallet' })
export class WalletEntity extends BasicEntity {
@PrimaryGeneratedColumn()
id: number;
@ManyToOne(() => UserEntity)
@JoinColumn({ name: 'user_id' })
user: UserEntity;
@Column({
name: 'address',
type: 'text',
})
address: string;
}
So, the wallet table is looks like this:
-------------------------
id | user_id | address
-------------------------
1 | 1 | 0x12
-------------------------
2 | 43 | 0x10
And I like to update the wallet entity via Repository api. But the problem is, that I can't just:
WalletRepository.save({ address: '0x12', userId: 2 })
Because Typescript give me an error, that userId should be userEntity, but not number. But I want to update a relation column. So is there any option to update it?