如何在自定义覆盖的操作中调用默认蓝图操作? [英] how to call default blueprint actions in a custom overridden one?

查看:38
本文介绍了如何在自定义覆盖的操作中调用默认蓝图操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SailsJS 提供默认的蓝图操作,例如查找、更新、创建等

SailsJS provides default blueprint actions, such as find, update, create, etc.

我需要覆盖其中一些以满足特定的业务目的.但是,我想添加到它们中,而不是简单地覆盖它们.如何在覆盖操作中调用默认蓝图操作.

I need to override some of them to suit particular business purposes. However, I would like to add to them, instead of simply override them. How to call the default blueprint actions in the overriding action.

例如,update 可以更新模型的记录.

For example, update can update the record of a model.

update 

除了更新模型的记录之外,我还想让更新做更多的事情.在我的自定义更新方法中,我不想重复默认更新.我该怎么做?

I want to have update do more, besides updating the record of a model. In my custom update method, I do not want to duplicate default update. How can I do that?

推荐答案

复制所有内容

PROJECT-ROOT\node_modules\sails\lib\hooks\blueprints\actions

PROJECT-ROOT\config\blueprints

确保 findOne.js 是小写的.您需要修改每一个以引用 actionUtil.js 的位置.您现在可以随意修改这些内容,而无需重新发明轮子.

Make sure findOne.js is lowercase. You will need to modify each one to make reference to the location of actionUtil.js. You can now modify these at your hearts content without re-inventing the wheel.

这篇关于如何在自定义覆盖的操作中调用默认蓝图操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆