vendure-ecommerce/vendure

Add columnId entity references for all relations

Opened this issue · 1 comments

Is your feature request related to a problem? Please describe.
One of things I often find annoying in Vendure is that many entity many to one relations don't expose the columnId. This often requires you to execute an additional query to retrieve the entity in services and generally leads to more query overhead and processing.

Vendure does this in some places but it's more an exception than a rule.

This would also be a great to have within the context of customFields

Describe the solution you'd like
Any entity in Vendure should expose a Many to One relation as both a reference and a column

  @Column()
  customerId: ID

  @Index()
  @ManyToOne(() => Customer, { nullable: false, onDelete: 'CASCADE' })
  customer: Customer

Describe alternatives you've considered
The alternative in most scenario's where this is an issue, is to retrieve the entity relation through a query.

This should also be combined with an optimizer for customFields entity relations. If you are just querying for the entity.id and no other field, the automatic entity resulution should not query for the relation and just return the { id }.