Ich löste dadurch ol 'schmutzige Workaround. Ich habe es unter folgender Adresse gefunden: https://github.com/strongloop/loopback/issues/651.
in der Datei meines Modells
module.exports = function(myModel) {
utils.disableAllMethodsButRemotes(myModel);
};
in meiner utils.js
Bibliotheksdatei:
ich endlich diesen Schnipsel herauskam
exports.disableAllMethodsBut = function(model, methodsToExpose) {
if (model && model.sharedClass) {
methodsToExpose = methodsToExpose || [];
var modelName = model.sharedClass.name;
var methods = model.sharedClass.methods();
var relationMethods = [];
var hiddenMethods = [];
try {
Object.keys(model.definition.settings.relations).forEach(function(relation) {
relationMethods.push({
name: '__findById__' + relation,
isStatic: false
});
relationMethods.push({
name: '__destroyById__' + relation,
isStatic: false
});
relationMethods.push({
name: '__updateById__' + relation,
isStatic: false
});
relationMethods.push({
name: '__exists__' + relation,
isStatic: false
});
relationMethods.push({
name: '__link__' + relation,
isStatic: false
});
relationMethods.push({
name: '__get__' + relation,
isStatic: false
});
relationMethods.push({
name: '__create__' + relation,
isStatic: false
});
relationMethods.push({
name: '__update__' + relation,
isStatic: false
});
relationMethods.push({
name: '__destroy__' + relation,
isStatic: false
});
relationMethods.push({
name: '__unlink__' + relation,
isStatic: false
});
relationMethods.push({
name: '__count__' + relation,
isStatic: false
});
relationMethods.push({
name: '__delete__' + relation,
isStatic: false
});
});
} catch (err) {}
methods.concat(relationMethods).forEach(function(method) {
var methodName = method.name;
if (methodsToExpose.indexOf(methodName) < 0) {
hiddenMethods.push(methodName);
model.disableRemoteMethod(methodName, method.isStatic);
}
});
if (hiddenMethods.length > 0) {
console.log('\nRemote mehtods hidden for', modelName, ':', hiddenMethods.join(', '), '\n');
}
}
};
exports.disableAllMethodsButRemotes = function disableAllMethodsBut(model) {
var remotes = Object.keys(model.definition.settings.methods || {});
return exports.disableAllMethodsBut(model, remotes);
};
ich es hilft zu Hause jemand
danke für den Austausch. Ich persönlich fühle mich mit der folgenden Option wohl, indem ich eine disableAllMethodsButRemotes-Funktion definiere – balanza
oh schön, habe nicht gemerkt, dass du es warst, der den Workaround gefunden hat! – richardpringle