get a relation key for side of OneToOne
See original GitHub issueIssue type:
[X ] question
Database system/driver:
[X ] mysql
/ mariadb
TypeORM version:
[X ] latest
How now it is possible to find out from which column they are related?
I performed a search I need links
getRepository (this.constructor) .metadata.findRelationWithPropertyPath ('l10n');
Expected Result: id_category
@Entity("categories", {})
export class CategoriesModel extends ORM {
@OneToOne(type => L10nCategoriesModel, l10n => l10n.categories, {
eager: true,
cascadeInsert: true,
cascadeUpdate: true,
cascadeRemove: true,
onDelete: 'CASCADE'
})
l10n: L10nCategoriesModel[];
}
@Entity("l10n-categories", {})
export class L10nCategoriesModel extends ORM {
/* id_category */
@OneToOne(type => CategoriesModel, category => category.l10n, {
onDelete: 'CASCADE'
})
@JoinColumn({
name: 'id_category',
})
categories: CategoriesModel;
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
One-to-one relations - typeorm - GitBook
One-to-one is a relation where A contains only one instance of B, and B contains only one instance of A. Let's take for...
Read more >The best way to map a @OneToOne relationship with JPA and ...
The best way to map a @OneToOne relationship is to use @MapsId . This way, you don't even need a bidirectional association since...
Read more >Choose owning side in OneToOne relation
The fix for this problem is simple. You just change the owning side and inverse side. Make the User entity the owning entity....
Read more >One-to-One Relationship in JPA - Baeldung
Learn three different ways to maintain a one-to-one relationship ... we only need it on the owning side of the foreign key relationship....
Read more >node.js - TypeORM OneToOne Relation Joined by Primary Key
After @PrimaryColumn add @OneToOne relation to the main table ... give you a single column for the Primary Key and the Foreign Key...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You can do it only from the owner side of the relationship this way:
Thank you!