如何覆盖环回js中的更新(放置)方法
How to override update (put) method in loopback js
根据环回文档,我们可以覆盖远程 methods.I 想要覆盖 PUT : /products/{id}
请求。
我试试这个:
module.exports = function (product) {
product.save = function(data,callback){
callback();
}
};
我尝试使用:update
、updateAttributes
、upsert
和所有相关方法,但仍然无法正常工作...
虽然重写 create
方法有效但 update
不行!
有什么建议吗?
使用product.prototype
可以触发put
这样的请求:
product.prototype.updateAttributes = function (data,callback) {
console.log('updateAttributes');
callback();
};
如果你想禁用API端点,你可以使用下面的,
Product.disableRemoteMethod('update', true)
Product.disableRemoteMethod('updateAttributes', true)
Product.disableRemoteMethod('upsert', true)
根据环回文档,我们可以覆盖远程 methods.I 想要覆盖 PUT : /products/{id}
请求。
我试试这个:
module.exports = function (product) {
product.save = function(data,callback){
callback();
}
};
我尝试使用:update
、updateAttributes
、upsert
和所有相关方法,但仍然无法正常工作...
虽然重写 create
方法有效但 update
不行!
有什么建议吗?
使用product.prototype
可以触发put
这样的请求:
product.prototype.updateAttributes = function (data,callback) {
console.log('updateAttributes');
callback();
};
如果你想禁用API端点,你可以使用下面的,
Product.disableRemoteMethod('update', true)
Product.disableRemoteMethod('updateAttributes', true)
Product.disableRemoteMethod('upsert', true)