-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Description
How I can create entity with foreign key without relation?
Sample entity:
@Table("post")
export class Post {
@PrimaryGeneratedColumn()
id: number;
@Column("bigint")
authorFk: number; // this field should be foreign key
author: Author;
}
It needs, because I'm know authorId, but I do not want to do 'SELECT' for get Author entity for create Post. Example:
...
let newPost = new Post();
newPost.authorFk = authorId;
...
this.Repository.persist(newPost);
...
In database authorFk isn't foreign key.
P.S. Entities are invented for the example
vuonghv