Closed cgoguyer closed 5 years ago
@raymondfeng @jannyHou, could you please with this question? Thanks.
@cgoguyer You probably need to hack the code in loopback/lib/persisted-model.js
using setRemoting
@jannyHou, I'm using a model based on "Model" to map custom third party API and I want to expose them as CRUD endpoints. I'm looking for a way to define the path for a method within the rest connector => map function apiCustomFind to / Thx.
@cgoguyer You can always define another model as the facade and use the REST model as the implementation for delegation. For example:
FacadeModel
GET /apiRoot/myModel
FacadeModel.find = function(...) {
FacadeModel.app.RestModel.find(...);
}
@raymondfeng, Ok, Facade Models is a good approach to solve this problem. Thx.
Hello, I have defined custom methods (via template) for find and findById and I'd like to change the default generated route by CRUD like routes.
With template I get the following routes: GET http://apiRoot/myModel/find and I'd like to have GET http://apiRoot/myModel GET http://apiRoot/myModel/findById/:id and I'd like to have GET http://apiRoot/myModel/:id
So how to change default route methods in rest connector ? Thank you.