【发布时间】:2019-02-28 22:43:39
【问题描述】:
我将sails 与postgresql 一起使用,并且我有一个具有一组组ID 的用户。我想将组 ID 保存在用户表中。我的用户模型是这样的:
module.exports = {
attributes: {
first_name: {
type: 'string'
},
last_name: {
type: 'string'
},
company: {
type: 'string'
},
password: {
type: 'string',
minLength: 6,
required: true,
columnName: "password"
},
user_groups: {
model: 'groups',
}
}
但是当我发送像 [2] 这样的请求时,我收到以下错误:
无法使用指定的
user_groups。期望一个 id 代表 关联的记录,或null表示不会有 相关记录。但指定的值无效user_groups。而不是数字(预期的 pk 类型),得到:[ 2 ]
【问题讨论】:
标签: node.js postgresql model sails.js waterline