【发布时间】:2017-01-12 19:25:57
【问题描述】:
当我尝试创建新的 CompanyProduct 时。我收到此错误
公司产品型号:
/**
* CompanyProduct.js
*
* @description :: This is a clients product inventory
* @docs :: http://sailsjs.org/#!documentation/models
*/
module.exports = {
tableName: 'company_products',
sortValues: ['companies', 'products'],
attributes: {
'quantity': {
'type': 'integer',
size: 6
},
'cost_per_unit': {
'type': 'integer'
},
// Associations
'product': {
'columnName': 'product_id',
'model': 'product',
'required': true
},
'company': {
'columnName': 'company_id',
'model': 'company',
'required': true
}
},
getSortValues: function() {
return this.sortValues;
}
};
【问题讨论】:
-
{ "error": "E_VALIDATION", "status": 400, "summary": "2 个属性无效", "model": "CompanyProduct", "invalidAttributes": { "quantity" : [ { "rule": "integer", "message": "
undefined应该是一个整数(而不是 \"10\",它是一个数字)" } ], "cost_per_unit": [ { "rule" : "integer", "message": "undefined应该是一个整数(而不是 \"100\",它是一个数字)" } ] } } -
您尝试从哪里创建模型?
CompanyProduct.create()或 http 请求还是什么?我们需要查看您尝试创建模型实体的代码!
标签: node.js sails.js waterline