没有主键的 Sails 1.0 模型
Sails 1.0 Models without primary key
我尝试使用新版本 1.0 并重构我的项目。我有一个问题,我现在不知道如何解决她。我的 BD 上的某些表没有主键,当我迁移到 sails 1.0 时,出现此错误
In model friends
: The primary key is set to id
, but no such
attribute was found on the model. You must define an id
attribute in
api/Friends.js
or in config/models.js
. See
http://sailsjs.com/upgrading#?changes-to-model-configuration for
info
我可以在没有主键的情况下使用我的模型吗?
我在更改主键时遇到了同样的问题:
在文件 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
},
}
我尝试使用新版本 1.0 并重构我的项目。我有一个问题,我现在不知道如何解决她。我的 BD 上的某些表没有主键,当我迁移到 sails 1.0 时,出现此错误
In model
friends
: The primary key is set toid
, but no such attribute was found on the model. You must define anid
attribute inapi/Friends.js
or inconfig/models.js
. See http://sailsjs.com/upgrading#?changes-to-model-configuration for info
我可以在没有主键的情况下使用我的模型吗?
我在更改主键时遇到了同样的问题: 在文件 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
},
}