1
如何保存在sails.js這個模型項目如何在sails.js中保存模型?
module.exports = {
attributes: {
name : {
en: {type: String},
fr: {type: String},
it: {type: String},
es: {type: String}
}
}
};
我試圖做這樣的 在控制器
module.exports = {
addItem: function(req, res) {
var params = {
en : req.body.en,
fr : req.body.fr,
it : req.body.it,
es : req.body.es
};
Items.addItem(params, function(success) {
res.json(success);
});
}
};
並在此之後我叫了服務
module.exports = {
addItem: function(params, next) {
Items.create({value: params}).exec(function(err, item) {
if(err) throw err;
next(item);
});
}
};
但當我嘗試發佈對象時出現以下錯誤 未知規則:en 如何解決此問題?由於
我想這是因爲'en'必須在'name' –
'恩:req.body.en, FR:req.body.fr, 它:req.body.it, es:req.body.es'檢查這個東西工作正常 –