I use TypeORM, and simply I want to insert a row by using relationId
. But it's not working as I expected.
Here is my entity:
@Entity()
export default class Address extends BaseEntity {
@Column({
type: 'varchar',
length: 255,
})
public title: number;
@Column({
type: 'varchar',
length: 2000,
})
public value: number;
@ManyToOne(type => User, user => user)
@JoinColumn({ name: 'userId' })
public user: User;
@RelationId((address: Address) => address.user)
public userId: number;
}
When I try to add like the below example, it adds null
userId
which I do not expect
{
"title": "My home address",
"value": "Lorep Ipsum Sit Amet",
"userId": 4
}
When I change the payload, everything works perfectly.
{
"title": "Ev adresim",
"value": "Nova Suites",
"user": 4
}
I do not want to use a payload like the above. I addicted to define a descriptive variable naming. Thanks for all contribution and all answer from now.