0
Sail 관련된 개체를 추가 한 후 다 대다 연관 관계가 저장 될 때 오류가 발생합니다. 여기 내 모델링입니다.연관된 개체에 레코드 추가 throw 및 오류 many-to-many 워터 라인 돛
User:
module.exports = {
attributes: {
...
operations: {
collection: 'operation',
via: 'users'
}
}
};
작업 : 내 사용자의 컨트롤러에
module.exports = {
attributes: {
...
users: {
collection: 'users',
via: 'operations',
}
}
};
, 내가 가진 :
여기addPermissionToUsers: function(req, res) {
Users.findOne(2).populate('operations').exec(function (err, user) {
if (err) throw err// handle error
// Queue up a record to be inserted into the join table
user.operations.add(1);
Save the user, creating the new associations in the join table
user.save(function (err) {
if (err) throw err
res.json(user)
});
});
}
오류 추적 있습니다 :
if (err) throw err
^
Error (E_UNKNOWN) :: Encountered an unexpected error
at new WLError (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/error/WLError.js:25:15)
at /usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/model/lib/defaultMethods/save.js:188:17
at /usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:52:16
at /usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:550:17
at /usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:544:17
at _arrayEach (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:85
'사용자'모델이 있습니까? – Sangharsh
예, 사용자가 있습니다. –
아니'사용자', 당신은'사용자'모델이 있습니까? 이 줄 ('collection : 'users',')는'User' 대신'Users' 모델을 참조합니다. – Sangharsh