0

Related: StrongLoop: hiding method updateAttributes(), but the accepted answer does not solve my problem.

I have followed the Get Started guide in order to get a basic app setup. In this app, my only model is called Pharmacy, and I would like to hide all mutating functions (i.e. delete, update,create...) from its REST API.

I am following the instructions in the documentation (http://docs.strongloop.com/display/public/LB/Exposing+models+over+REST#ExposingmodelsoverREST-HidingmethodsandRESTendpoints). While I can hide the static functions just fine, the updateAttributes method is still being exposed no matter what I do.

I have placed my hiding logic in common/models/pharmacy.js. Placing it in server/pharmacy.js as indicated by the docs does nothing, as the file is not even loaded.

The content of common/models/pharmacy.js is:

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;
};

What am I doing wrong? Thanks in advance!

Community
  • 1
  • 1
csvan
  • 8,782
  • 12
  • 48
  • 91

1 Answers1

1

Managed to solve this after a very helpful email from the devs. The file should look like this:

module.exports = function(Pharmacy) {
        Pharmacy.disableRemoteMethod('deleteById', true);
        Pharmacy.disableRemoteMethod('updateAttributes', false);
        Pharmacy.disableRemoteMethod('updateAll', true);
        Pharmacy.disableRemoteMethod('upsert', true);
        Pharmacy.disableRemoteMethod('create', true);
};
csvan
  • 8,782
  • 12
  • 48
  • 91