Skip to content

[2.0] Programmatically defined modes vs. public/shared #345

Closed

Description

@fabien

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.

Activity

  1. bajtos commented on Jun 24, 2014

    @bajtos
    Member

    Does this workaround solve the problem?

    app.model(Model, { public: false });
  2. added this to the milestone on Jun 24, 2014
  3. changed the title [-]Programmatically defined modes vs. public/shared[/-] [+][2.0] Programmatically defined modes vs. public/shared[/+] on Jun 24, 2014
  4. fabien commented on Jun 24, 2014

    @fabien
    ContributorAuthor

    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.

  5. bajtos commented on Jun 24, 2014

    @bajtos
    Member

    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.

  6. raymondfeng commented on Jun 24, 2014

    @raymondfeng
    Member

    @bajtos Is 14c73cb relavant?

  7. bajtos commented on Jun 25, 2014

    @bajtos
    Member

    @raymondfeng Is 14c73cb relavant?

    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.

  8. raymondfeng commented on Jul 7, 2014

    @raymondfeng
    Member

    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.

  9. bajtos commented on Jul 8, 2014

    @bajtos
    Member

    What other effects does app.model(MyModel) have beyond remoting?

    It adds the model to app.models lookup table.

    I tend to agree with @fabien here. What's the point of the property Model.shared if 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?

  10. fabien commented on Jul 8, 2014

    @fabien
    ContributorAuthor

    @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.

  11. bajtos commented on Jul 8, 2014

    @bajtos
    Member

    Cool, I'll comment in #346.

  12. modified the milestone: #Rel lb 2.0.0 on Sep 30, 2014
  13. bajtos commented on Nov 13, 2014

    @bajtos
    Member

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions