Closed YuriScarbaci closed 5 years ago
I don't know much about ember-orbit, can you tell me more about your intended use case?
I don't know much about ember-orbit, can you tell me more about your intended use case?
Sure:
I got a component that uses withData
and among other things it retrieves multiple instances of the model (let's say) user
, the user
model defines a hasOne
relationship with the model (let's say) BestFriend
I generate a table of user where I want to print every retrieved User
and in the same table i want to print 2 columns of the single User
BestFriend.attributes.name
& BestFriend.attributes.surname
Logging every single user istance results in the relationship BestFriend
to be present and working (meaning that it contains type
& id
) but I noticed the lack of helpers methods to acces the related data attributes.
What i would like to be able to do is invoking a getter function on the User
instance where i define the relationship defined in my schema to populate the relationships fields.
Something like currentUserInstance.get('BestFriend').attributes.name
.
The only way to achieve this right now (atleast in the indexedDb source) is to manually invoke queryStore(q=>q.findRecord({type:'type from the relationship descriptor',id:'id from relationship descriptor'}))
manually on every single user instance, would be extra nice if the get
method could syntactical sugar coat
the process...
Got it.
It's however not really the goal for this project to provide a model/orm layer on top of Orbit, merely a reactive subscription/listener pattern to bind React and Orbit together.
Maybe https://github.com/exivity/orbit-client might be a better place for such functionality. /cc @Michiel87
in relation with the OrbitJS official documentation at
https://github.com/orbitjs/ember-orbit#updating-records
I'm trying to access the attributes of a related record of a model retrieved with react-orbitjs but it looks like react-orbitjs doesn't expose the getter/setters functions the way ember-orbit does, as I get the error.get is not a function
is there any way to lazy load a relationship or otherwise access a given relationship attributes? the
relationship identificator --> querying for the given id
isn't applicable for my usecase...