Skip to content

Foreign key without relation #188

@CocaColaBear

Description

@CocaColaBear

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions