【发布时间】:2018-08-22 12:13:42
【问题描述】:
我不断收到此错误。
The primary key is set to `id`, but no such attribute was found on the model.
我在数据库中的表没有使用任何主键,也没有关于如何在sails中禁用主键属性的教程。
有没有办法让我在不指定 id 属性或主键的情况下查询模型?
【问题讨论】:
我不断收到此错误。
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
{
【讨论】: