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
{{ message }}
Repository navigation
[2.0] Programmatically defined modes vs. public/shared #345
In the 2.0 branch, when registering a programmatically defined model that has been explicitly set with Model.shared = false, is still exposed. app.model(Model) forces shared to be true, and pays no regard to the previously set value of Model.shared.
For posterity, I think it is a good idea to fix app.model to honor Model.shared in case there is no config supplied. We should consider back-porting that fix to 1.x too, though I am not sure if such change is backwards compatible.
That commit is not changing the behaviour. What is needed - when there is only one parameter, set isPublic = Model.shared. Or even better, refactor the code to get rid of isPublic, as I suggested in PR#320.
What other effects does app.model(MyModel) have beyond remoting? If nothing else, I would argue app.model(MyModel) should expose the model as REST regardless of shared as that's the only purpose of the API.
@bajtos see #346 - I rely on getModel for a unified access to models by name. It feels more as a public API than accessing app.models directly, so I expected it to be the way to go - even for 'embedded' models.
Activity
bajtos commentedon Jun 24, 2014
Does this workaround solve the problem?
[-]Programmatically defined modes vs. public/shared[/-][+][2.0] Programmatically defined modes vs. public/shared[/+]fabien commentedon Jun 24, 2014
Actually, I'm running 2.0.0-beta3, not 2.0 branch - sorry. Looking through the code, it seems that this should work - will try later. Thanks.
bajtos commentedon Jun 24, 2014
For posterity, I think it is a good idea to fix
app.modelto honorModel.sharedin case there is no config supplied. We should consider back-porting that fix to 1.x too, though I am not sure if such change is backwards compatible.raymondfeng commentedon Jun 24, 2014
@bajtos Is 14c73cb relavant?
bajtos commentedon Jun 25, 2014
That commit is not changing the behaviour. What is needed - when there is only one parameter, set
isPublic = Model.shared. Or even better, refactor the code to get rid ofisPublic, as I suggested in PR#320.raymondfeng commentedon Jul 7, 2014
What other effects does
app.model(MyModel)have beyond remoting? If nothing else, I would argue app.model(MyModel) should expose the model as REST regardless ofsharedas that's the only purpose of the API.bajtos commentedon Jul 8, 2014
It adds the model to
app.modelslookup table.I tend to agree with @fabien here. What's the point of the property
Model.sharedif it isn't honoured in loopback?@fabien Could you please provide more details? What is your purpose for calling
app.model(MyModel)for models that are not exposed via REST?fabien commentedon Jul 8, 2014
@bajtos see #346 - I rely on getModel for a unified access to models by name. It feels more as a public API than accessing app.models directly, so I expected it to be the way to go - even for 'embedded' models.
bajtos commentedon Jul 8, 2014
Cool, I'll comment in #346.
bajtos commentedon Nov 13, 2014
I am closing this issue as there was no update for 4 months and the comments make me believe the discussion has been moved to #346