Closed simoami closed 8 years ago
The included object is not a regular property of the model. The constructor probably should pass in a flag to ensure schema-less conversion.
I used RemoteObjects.invoke() because it was the only way I could run acl and before / after hooks for a given method. Any other ways you'd suggest?
Model.checkAccess() has the logic to trigger ACLs.
hmm, I considered that path a week ago. if I am to to recode the whole logic for orchestrating calls (checkACL, call before hooks, call after hooks...) , my implementation could become vulnerable to future updates.
I see that the Model constructor has a strict
property, which could potentially be used for retaining related properties.
what do you think?
or even better, have a flag to skip model transformation or keep source JSON in the model, like __sourceData
.
Update: I see that the relations are not exactly lost. They're being stored in model.__cachedRelations.
I think I'd just merge that with __data into a new json object.
@simoami Looks like you solved the issue. Anyway, I think if any related issues come up they should go to LoopBack since it involves both the Model Class as well as strong-remoting.
@richardpringle I did not solve the issue. I just helped figure this out and offering ways to solve it. It has been some time and I can't remember if I ended up using __cachedRelations. In any case, fine to close for now.
@simoami, sorry to hear that it didn't get completely solved. As I said, better to open in LoopBack next time. Can always mention me directly to try and get the issue solved a little faster too.
I just discovered that if you invoke a rest method with remoteObjects.invoke(), the included related models are stripped. This is a side effect of converting the returned json into a model instance in HttpInvocation logic.
Demonstration: