Skip to content

Enable relation methods targetting Models not exposed via REST API #124

@bajtos

Description

@bajtos

Cross-posting from https://groups.google.com/forum/#!topic/loopbackjs/pyk5B4-SFzs:

I have the following models:

Customer
Group

Customer hasMany Groups
Group belongsTo Customer

In the API I don't want to expose Group endpoints (i.e /api/groups/), but I do want to expose /api/customers/:id/groups

Recently I change my model-config.json to disable public access to the Groups endpoint.

"Group": {
    "dataSource": "db",
    "public": false
}

This disabled the endpoint in Explorer, and I was still able to make a call to /api/customers/:id/groups

However, I just noticed the following warning in the lb-service.js generatioin:

[2015-01-27T16:10:58.096Z] [ERROR] Warning: scope Customer.groups targets class "Group", which is not exposed
via remoting. The Angular code for this scope won't be generated.

This explains why the code in lb-services.js wasn't working. So the question then is can the lb-services generation be modified to include access to the relations (/api/customers/:id/groups) and restrict access to the base model (i.e /api/groups)?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions