是否可以在sails.js中的回调覆盖中获取模型定义?

时间:2016-01-14 22:17:17

标签: sails.js waterline

我正在研究与Can I specify a lifecycle callback that fires for all waterline models in sails?类似的东西。

我希望能够在回调中引用模型定义,但只有属性和id当前被发送到afterUpdate。有没有办法确定我使用的模型,除了添加' type'作为属性?

1 个答案:

答案 0 :(得分:1)

正确的范围加this将适用于 config / models.js

module.exports.models = {

    attributes: { . . .},

    afterUpdate: function (model) {
        console.log(this.identity);  //model name that triggered callback
        console.log(this.definition); //model definition

        //logic . . .
    }
};
相关问题