相关:StrongLoop: hiding method updateAttributes(),但接受的答案并不能解决我的问题。
我已按照“使用入门”指南进行基本的应用设置。在这个应用程序中,我唯一的模型叫做Pharmacy,我想从REST API中隐藏所有变异函数(即删除,更新,创建......)。
我按照文档(http://docs.strongloop.com/display/public/LB/Exposing+models+over+REST#ExposingmodelsoverREST-HidingmethodsandRESTendpoints)中的说明操作。虽然我可以很好地隐藏静态函数,但无论我做什么,updateAttributes方法仍然会被暴露。
我将隐藏逻辑放在common / models / pharmacy.js中。如文档所示,将它放在server / pharmacy.js中没有任何作用,因为文件甚至没有加载。
common / models / pharmacy.js的内容是:
module.exports = function(Pharmacy) {
Pharmacy.sharedClass.find('deleteById', true).shared = false;
Pharmacy.sharedClass.find('updateAttributes', false).shared = false;
Pharmacy.sharedClass.find('upsert', true).shared = false;
Pharmacy.sharedClass.find('create', true).shared = false;
};
我做错了什么?提前谢谢!
答案 0 :(得分:1)
管理来自开发者的一封非常有用的电子邮件后解决这个问题。该文件应如下所示:
module.exports = function(Pharmacy) {
Pharmacy.disableRemoteMethod('deleteById', true);
Pharmacy.disableRemoteMethod('updateAttributes', false);
Pharmacy.disableRemoteMethod('updateAll', true);
Pharmacy.disableRemoteMethod('upsert', true);
Pharmacy.disableRemoteMethod('create', true);
};