node.js - 风 sails JS : How to disable primary key attribute?

标签 node.js sails.js

我不断收到此错误。

The primary key is set to `id`, but no such attribute was found on the model.

我在数据库中的表不使用任何主键,并且没有关于如何在 sails 中禁用主键属性的教程。

有没有办法让我在不指定 id 属性或主键的情况下查询模型?

最佳答案

您的模型中需要有某种主键。 sails 文档建议的方法是仍然使用“id”属性,但给它一个自定义的columnName。例如在模型中:

id: {
    type: 'number',
    columnName: 'employeeID',
    required: true
{

关于node.js - 风 sails JS : How to disable primary key attribute?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51966645/

相关文章:

javascript - 使用 passport.js、sails.js 和 sails 生成身份验证保护页面

javascript - Node Canvas 图像抗锯齿似乎不起作用

node.js - Sails JS - 如何将用户 api 模型连接到 Couchbase 中的用户存储桶?

javascript - promise : execute after loop

javascript - 将参数传递给带有变量的函数或在传递过程中进行修改

node.js - 如何正确调试 Sails.js 中的响应生命周期?

javascript - 当包含 ember-data 时,TypeError DS.RESTAdapter 未定义

ios - Ionic 在 iOS 上构建和模拟 - 错误

node.js - 如何通过 NodeJS REST 请求添加文件附件

javascript - 如何传递错误的变量