0
votes

I've managed to take out some of the predefined methods from my rest API using this code which I adapted from the documentation:

var app = require('../app');
var News = app.models.News;

News.create.shared = false;
News.upsert.shared = false;
News.deleteById.shared = false;

However, this same code breaks when I try to hide the updateAttributes() predefined method. Does anyone know how come this is?

2
Where did you put this code? The link is broken, and I ask because I am having the same problem.csvan
In Loopback 2, just create a new .js file, name it after your model, e.g. common/models/news.js and put this code in it.kYuZz
Yea that is how I ended up solving it - much of the documentation unfortunately seems to be outdated or simply wrong. In this case it instructed me to simply place the file in the server dir, which of course accomplished nothing.csvan

2 Answers

3
votes

You should do:

News.prototype.updateAttributes.shared = false;
2
votes

The one provided by Raymond did not work for me

I used this

MyModel.disableRemoteMethod('updateAttributes', false);

Which is stated in the Strongloop docs; the key here is the false.