0
私はSailsJsに新たなんだと私はデフォルトのメソッドを介してオーバーライドを実行するには、例えば、足場を生成:SailsJs - 上書きコントローラのデフォルトメソッド
を
を作成しますので、アイデアがにありますcreateへの呼び出しの前にsomeStuff()を実行します。基本的に、スキャフォールディングの後に出てくるデフォルトの作成の前にいくつかの機能を追加していますが、コードを書き直すことを避けるためにその機能を呼びたいと思います。
私が実行するコマンドは次のとおりです。ここで
sails generate api user
は私のコントローラのコードである:ここで
/**
* UserController
*
* @description :: Server-side logic for managing users
* @help :: See http://sailsjs.org/#!/documentation/concepts/Controllers
*/
module.exports = {
create: function (req, res) {
someStuff();
call_to_default_create()<--- What to know if posible?
},
};
は、モデルのコードです:
/**
* User.js
*
* @description :: TODO: You might write a short summary of how this model works and what it represents here.
* @docs :: http://sailsjs.org/documentation/concepts/models-and-orm/models
*/
module.exports = {
attributes: {
name: {
type: 'string',
required: true,
minLength: 2
},
last_name: {
type: 'string',
required: true,
minLength: 2
},
email: {
type: 'string',
email: true,
required: true,
unique: true
},
encrypted_password: {
type: 'string'
}
}
}
私は帆を動作する方法は、継承ではないと思われるが、私は何とかこれをエミュレートすることができます?
ありがとう、私はこれを適用し、それが動作します。 –