有没有已知的方法可以禁用特定的 blueprints
在 sails.js
中的每个 Controller 级别?
我已经阅读了如何禁用所有 blueprints
在应用程序级别,以及如何禁用所有 blueprints
对于个人 controller
但是有没有办法禁用 blueprints
的子集个人 controller
?
本文档涵盖了基础知识,包括禁用所有 blueprints
每个 Controller ,
https://github.com/balderdashy/sails-docs/blob/master/reference/blueprint-api/blueprint-api.md
但是说我有一个 Counties
模型,我想要 find
可用操作( find()
和 findOne()
),但不想要其他操作。
这是一个选择吗?
最佳答案
您可以在 Controller 中覆盖它们。例如,
update: function (req, res) {
res.forbidden();
},
destroy: function (req, res) {
res.forbidden();
}
这是一种方式。其他更受欢迎的方法是使用策略:
myController: {
'find': true,
'findOne': true,
'*': false
},
这只会暴露 find 和 findOne 并隐藏其他操作
关于sails.js - 您可以禁用特定 Controller 上的某些蓝图吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26984204/