gpt4 book ai didi

sails.js - 您可以禁用特定 Controller 上的某些蓝图吗?

转载 作者:行者123 更新时间:2023-12-04 23:49:11 25 4
gpt4 key购买 nike

有没有已知的方法可以禁用特定的 blueprintssails.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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com