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
How to hide relation API endpoints from explorer? ex. GET /parents/{pk}/childs #563
changed the title [-]How to hide relation API endpoints from explorer? like GET /parents/{pk}/childs[/-][+]How to hide relation API endpoints from explorer? ex. GET /parents/{pk}/childs[/+]on Sep 14, 2014
AFAIK, the relation methods are created when the model is attached to a datasource, which happens later in the application lifecycle. To disable a relation method, you have to make the change after the model was attached.
@raymondfeng@ritch I remember one of you was commenting on this same problem elsewhere, could you please confirm the solution above is the correct one?
Activity
[-]How to hide relation API endpoints from explorer? like GET /parents/{pk}/childs[/-][+]How to hide relation API endpoints from explorer? ex. GET /parents/{pk}/childs[/+]cajoy commentedon Sep 19, 2014
I have the same question.. Seems like there is no loopback developers.
bajtos commentedon Sep 20, 2014
AFAIK, the relation methods are created when the model is attached to a datasource, which happens later in the application lifecycle. To disable a relation method, you have to make the change after the model was attached.
@raymondfeng @ritch I remember one of you was commenting on this same problem elsewhere, could you please confirm the solution above is the correct one?
bajtos commentedon Sep 20, 2014
@crandmck please update the documentation once a working solution is confirmed.
clark0x commentedon Sep 20, 2014
@bajtos It won't work currently. check discuss on #410, strongloop/strong-remoting#94, and PR strongloop/strong-remoting#95
tonysoft commentedon Oct 2, 2014
Parent.on('attached', function() {
Parent.sharedClass.find('__get__students', false).shared = false;
});
Seems as though ".find" above returns a Class one level higher than needed for this purpose. I had to access ".fn" to get this to work.
Parent.sharedClass.find('__get__students', false).fn.shared = false;
raymondfeng commentedon Oct 2, 2014
Can you try https://github.com/strongloop/loopback/blob/master/lib/models/model.js#L392?
tonysoft commentedon Oct 2, 2014
IT DOES WORK... Ignore my comment here below... I had omitted the second Argument that Ritchie mentions in his comment below...
Sorry...
I tested that and it DOES NOT work Raymond... I then use the technique I
outlined in my comment and it does work...
It certainly would be the cleaner way to do it though...
On Thu, Oct 2, 2014 at 11:13 AM, Raymond Feng notifications@github.com
wrote:
ritch commentedon Oct 2, 2014
As of loopback
2.4.0you can do:@bajtos @tonysoft @clarkorz @cajoy
raymondfeng commentedon Oct 3, 2014
I just confirmed it works with latest loopback. In my case, I added common/models/post.js:
The three relation methods to tags are now disabled in the api explorer.
veekungx commentedon Oct 4, 2014
WOW!!!! thx for your hard work. I wanna add more than 1 star on LB.