我尝试使用新版本 1.0 并重构我的项目。我有一个问题,但我现在不知道如何解决她。我的 BD 上的某些表没有主键,当我迁移到 sails 1.0 时,出现此错误
模型中friends
:主键设置为id
,但没有这样的
在模型上找到属性。您必须定义一个id
属性在api/Friends.js
or in config/models.js
. See
http://sailsjs.com/upgrading#?changes-to-model-configuration为了
信息
我可以在没有主键的情况下使用我的模型吗?
我有同样的问题,我用来更改主键:
在文件 config/model.js 中
attributes: {
id: {
type: 'number',
autoIncrement: true,
},
}
and in the model api/any_model.js i used:
tableName : 'table',
attributes: {
id: {
type: 'number',
columnName : 'column_you_like_to_be_a_primaryKEY',
required : true
},
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)