在Sails1.0中,我尝试使用sails-mongo进行开发和生产,使用sails-disk进行测试。在1.0版本之前,我可以这样做,但现在我收到一个错误:
error: Error: In model 'user', primary key 'id' must have either
'required' or 'autoIncrement' set.我的代码:
module.exports = {
attributes: {
createdAt: { type: 'number', autoCreatedAt: true },
updatedAt: { type: 'number', autoUpdatedAt: true },
id: { type: 'string', columnName: '_id' }, //<---- error Here!
name: {
type: 'string',
required: true
},
......
}我可以做一些变通方法来使它工作吗?
发布于 2018-03-29 15:39:56
在id字段中添加required规则。
module.exports = {
attributes: {
createdAt: { type: 'number', autoCreatedAt: true },
updatedAt: { type: 'number', autoUpdatedAt: true },
id: { type: 'string', columnName: '_id', required: true }, //<---- Add it here
name: {
type: 'string',
required: true
},
......
}https://stackoverflow.com/questions/49540671
复制相似问题