You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Usecase:
We want to add a relation Product to User (called owner) to implement an ownership. For access controll we only need the user id from the product to compare it with the activeUserId of the RequestContext. Right now, the user needs to be eagerly loaded to access the id, therefore it would be awesome if we could just access the id directly from the column in the entity table
Instead of: product.customFields.owner.id
We could directly access the id via: product.customFields.ownerId
Describe the solution you'd like
For own entities we can achieve this in TypeORM by adding a relational definition and a defintion of the relation id to an entity:
@OneToOne(()=>User,{onDelete: 'CASCADE'})
owner: User;// This will add the column ownerId to the entity
@EntityId()
ownerId: ID;// With this we can directly access the data from the column
This TypeORM definition should be created by a custom fields configuration like this:
config.customFields.Product.push({name: 'owner',nullable: true,type: 'relation',entity: User,public: false,readonly: true,withId: true,// a option like this could add the extra definition});
To prevent breaking changes, the option shall be false by default for the next minor versions.
The text was updated successfully, but these errors were encountered:
Attempting to implement #2031 but it is proving
quite difficult to make everything work.
I added a new e2e test, but the current implementation breaks
existing tests as well as not fully passing the new test.
This is proving much more difficult to implement correctly than I had imagined. I spent a couple of hours trying to debug the problems but I'm not there yet. The WIP is in the branch linked above. I need to return to this when I have more time to dedicate to debugging it.
Is your feature request related to a problem? Please describe.
Usecase:
We want to add a relation
Product
toUser
(calledowner
) to implement an ownership. For access controll we only need the user id from the product to compare it with theactiveUserId
of theRequestContext
. Right now, the user needs to be eagerly loaded to access the id, therefore it would be awesome if we could just access the id directly from the column in the entity tableInstead of:
product.customFields.owner.id
We could directly access the id via:
product.customFields.ownerId
Describe the solution you'd like
For own entities we can achieve this in TypeORM by adding a relational definition and a defintion of the relation id to an entity:
This TypeORM definition should be created by a custom fields configuration like this:
To prevent breaking changes, the option shall be
false
by default for the next minor versions.The text was updated successfully, but these errors were encountered: