mwo*_*ton 2 mysql sails.js waterline
我正在尝试在表中创建记录,它与其他现有模型共享一些属性.
// model:
module.exports = {
attributes: {
...
contentType: 'string', // This is a combination foreign-key,
// which is not currently
content: 'number', // supported in waterline
...
}
}
// creating code:
sails.log('item.content:', typeof item.content, item.content);
UserContentLibrary.create({
user: prodSubscription.user,
productContentSubscription: pcs.id,
contentType: item.contentType,
content: item.content,
}, function uclCreateCB(err, ucl){
if (err){
sails.log.error(err);
}
itemDone();
});
// error (console output):
debug: item.content: number 3
error: Error (E_VALIDATION) :: 1 attribute is invalid
...
Invalid attributes sent to UserContentLibrary:
content
`undefined` should be a number (instead of "30", which is a string)
Run Code Online (Sandbox Code Playgroud)
从调试日志记录中可以看出,item.content确实是一个数字,但由于某种原因,它在某处转换为字符串,可能是适配器.我怎么能绕过这个?
| 归档时间: |
|
| 查看次数: |
1328 次 |
| 最近记录: |