Pat*_*ign 5 mysql node.js sails.js
我在SailsJS中创建了一个新模型,其中自定义ID名称作为主键.我想利用SailsJS附带的蓝色打印路线,但是当我尝试去时,/name/1我得到下面的错误.
ER_BAD_FIELD_ERROR: Unknown column 'id' in 'where clause'
Run Code Online (Sandbox Code Playgroud)
似乎Sails仍在寻找默认表名'id'而不是我的新自定义ID.关于如何让Sails实现我的变化的任何想法?
谢谢
Rah*_*nna 10
转到模型定义并最后添加autoPK:false.
module.exports = {
schema:'true',
attributes: {
propertyName: { type:"string", required:true, unique: true }
},
autoPK:false
}
Run Code Online (Sandbox Code Playgroud)
Okay I looked through SailsJS src and found in node_modules/sails/node_modules/waterline/lib/waterline/query/finders/basic.js on line 37 that checks for the property 'autoPK'. This property is set to true by default and looks for the field 'id'. By setting 'autoPK: false' in my model it will check to see if you have set a custom Primary Key and will use that instead. All Fixed.
| 归档时间: |
|
| 查看次数: |
2204 次 |
| 最近记录: |