Skip to content
This repository has been archived by the owner on Oct 10, 2022. It is now read-only.

Add RelationId to Column decorated properties #226

Open
boenrobot opened this issue Nov 14, 2019 · 2 comments
Open

Add RelationId to Column decorated properties #226

boenrobot opened this issue Nov 14, 2019 · 2 comments
Labels
enhancement new feature or bug with easy workaround

Comments

@boenrobot
Copy link
Contributor

boenrobot commented Nov 14, 2019

See this comment.

If a relation has only one column identifying it, and is the owning relation (or either side in a 1:1 relation), it's more concice to have that one @Column decorated property also contain a @RelationId decorator for it. A column may contain multiple @RelationId decorators for each such relation.

If a relation is not the owning relation or has multiple columns forming its join, there won't be a relation ID anyway I guess.

On a related note, as per typeorm/typeorm#4112, it seems @RelationId is not supported for lazy relations, so I guess the command line option needs to change to allowing neither, eager only, lazy only, or both, with true being alias for "eager only" until TypeORM adds support for lazy, at which point it could become "both".

@Kononnable Kononnable added the enhancement new feature or bug with easy workaround label Dec 14, 2019
@Kononnable
Copy link
Owner

with true being alias for "eager only"

In typeorm there are three kinds of relationships(in terms on when it is loaded):

  • eager
  • promise based(known as lazy)
  • standard

'Standard' relationship(without lazy and eager options) works as lazy, but they're not wrapped in a promise. RelationId field works with eager and standard relatonships.

@boenrobot
Copy link
Contributor Author

boenrobot commented Jan 2, 2020

Huh... I didn't know there was a 3rd category. I thought there's only "lazy" and "eager". Well, no wonder I guess, given they're both the same type.

The related doc page at TypeORM doesn't seem to make this distinction... The eager relations have no indication of them being either eager or lazy, but given the title of the section, one assumes "eager" = "not lazy".

EDIT: Wait, nevermind... There's eager: true in the second file from that section... I guess I was just missing the explanation on how "standard" relations work compared to "eager".

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement new feature or bug with easy workaround
Projects
None yet
Development

No branches or pull requests

2 participants