隐藏相关模型的方法
如何隐藏相关模型的方法?
比方说,在demo app loopback-example-datagraph中 ,我不想公开DELETE /customers/{id}/orders
方法。
我应该怎么做呢?
对于回送1.x,该关系在内部映射到原型方法。 要不将其作为REST API公开,请尝试以下操作:
var customer = app.models.Customer; customer.prototype.__delete_orders.shared = false;
免责声明我从来没有使用StrongLoop
狂野的刺,但它看起来像这可能工作。 当你添加一个关系的时候,它会在底层模型类中添加一个方法。 当你添加了很多它增加了这个方法
customer.orders.destroyAll(function(err) { ... });
来源: http : //docs.strongloop.com/display/DOC/Creating+model+relations#Creatingmodelrelations-Methodsaddedtothemodel.1
你应该可以这样说
var customer = app.models.Customer; customer.orders.destroyAll.shared = false;