我没有设法在LoopBack 2.0中隐藏API方法。

根据documentation,我应该通过以下方式实现此目的:

var app = require('../app');
var Location = app.models.Location;
Location.deleteById.shared = false;


但是,这似乎不起作用。

另外,console.log(Location.deleteById)打印:

[Function]


如果deleteById是函数而不是对象,则对shared属性的分配没有任何意义。毫不奇怪,console.log(Location.deleteById.shared)打印:

undefined


有任何线索吗?

最佳答案

您应该会看到新的文档,

http://docs.strongloop.com/display/public/LB/Exposing+models+over+REST#ExposingmodelsoverREST-HidingmethodsandRESTendpoints

这对我有用

MyModel.disableRemoteMethod('deleteById', true);

09-25 21:13