SailsJS and mySQL custom ID name not working with blue prints

╄→гoц情女王★ 提交于 2019-12-05 10:42:24
Rahat Khanna

Go to your model definition and add the autoPK:false at last.

module.exports = {

  schema:'true',
  attributes: {
    propertyName: { type:"string", required:true, unique: true }
  },
  autoPK:false
}

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!