@tschoartschi wrote:
Hey!
I have the following problem:
I want to read the ID of an async belongsTo relation without loading the whole record from the server.
Background: We have a user model and a plan model. The plan model has a belongsTo relation to a user. Now a user can share his plans to other users. To determine if a plan is shared or not, we compare the user-id of the actual authenticated user and the user-id which is in the belongsTo relation of the plan. If I do the following in the plan route:
if(this.get('session.data.authenticated.auth.userId') !== this.get('model.user.id') { //... //... }
The user is fetched but we don't want that every user can fetch every others user details. The backend returns
http 403
->forbidden
. Now I tried to get around this issue with some internal private members which seems very hackish to me. When I access the user.id of the plan with:model.get('_internalModel._relationships.initializedRelationships.user.canonicalState.id')
I get the id without a server request. Is there a public API to do this or is my hackish way the only way to solve this issue?
Thanks a lot Bye
Posts: 2
Participants: 2