1

How can I hide a method for a related model?

Let's say that, in the demo app loopback-example-datagraph, I don't want to expose the DELETE /customers/{id}/orders method.

How should I go about this?

4

2 回答 2

2

对于环回 1.x,关系在内部映射到原型方法。要不将其公开为 REST API,请尝试以下操作:

var customer = app.models.Customer;
customer.prototype.__delete_orders.shared = false;
于 2014-06-10T16:16:27.947 回答
0

免责声明我从未使用过 StrongLoop

野刺,但看起来这可能会奏效。当您添加关系时,它会向底层模型类添加一个方法。当您添加一个有很多时,它会添加此方法

customer.orders.destroyAll(function(err) {
  ...
});

来源:http ://docs.strongloop.com/display/DOC/Creating+model+relations#Creatingmodelrelations-Methods addedtothemodel.1

你应该可以说类似

var customer = app.models.Customer;
customer.orders.destroyAll.shared = false;
于 2014-06-10T15:51:07.380 回答