javascript - Sails.js - 如何避免 Sails JS 在数据库表上查找 Id(因为该表没有 id 列)

标签 javascript node.js database postgresql sails.js

我是 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 的列是:

  1. 姓名

  2. 地址

  3. 身份证号码

如何避免 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/

相关文章:

javascript - SPF.js 导航到新 URL 后如何保持页面的当前位置

node.js - elastic beanstalk 中的多个 Nodejs 应用程序

MySQL - 按行列表中的特定值分组

android - 更新Assets文件夹的解决方法

php - 使用 PHP 从数据库获取图像

javascript - ($ ('.class-name' ).is (":checked")) 从来不为真

javascript - 需要 Javascript 显示两个隐藏的 css div

javascript - Angular JS - 具有嵌套范围的 http 请求错误

javascript - 如何使用 ExpressJS 和 Nodejs 在控制台中记录 res.locals 内容以进行调试?

node.js - 你似乎不依赖于 "@angular/core and/or "rxjs”。这是一个错误