我是 Sails JS(基于 Node JS)的新手。我收到错误:
[Error (E_UNKNOWN) Encountered an unexpected error] Details: error: column MyTable.id does not exist
当我执行这个语法时出现错误:
MyTable.find().then(function (locations) { .. }.catch(function (err) { .. }
错误显示我的表没有 id 列。我的表没有 id 列,我不想添加“id”列(因为在我使用 sails 为该数据库创建 API 之前,该数据库已经存在)。
MyTable 的列是:
姓名
地址
身份证号码
如何避免 Sails JS + Waterline 搜索“id”列?
最佳答案
module.exports = {
autoCreatedAt:false,
autoUpdatedAt:false,
id:false,
tableName: 'jobs_cats',
attributes: {
pc_id: {
type: 'integer',
primaryKey: true,
autoIncrement: true
},
project_id: 'integer',
cat_id: 'integer'
}
关于javascript - Sails.js - 如何避免 Sails JS 在数据库表上查找 Id(因为该表没有 id 列),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48070004/