설명서 및 github 문제를 살펴 보았습니다.루프백 모델이 업데이트되지 않음 - 루프백 : 오류 : 관계 "chatroomID"가 ChatMessage 모델에 정의되지 않았습니다.
https://loopback.io/doc/en/lb2/HasMany-relations.html
https://github.com/strongloop/loopback-datasource-juggler/issues/76
hasMany relation: including from the other direction
내가 왜이 오류가 발생 된 내 손가락을 넣어 없습니다 : Error: Relation "chatroomID" is not defined for ChatMessage model
비록 내가 제대로 내 JSON을 편집 한 것으로 보인다
, 내 대화방 모델이 업데이트되지 않습니다 (REST 탐색기에서 볼 수 있음)
하지만 chatmessage 업데이트하는 관리 않았다
채팅 - message.json
{
"name": "ChatMessage",
"base": "PersistedModel",
"idInjection": true,
"options": {
"relations": {
"ChatRoom": {
"type": "belongsTo",
"model": "ChatRoom",
"foreignKey": "chatroomID"
},
...
채팅 - room.json
{
"name": "ChatRoom",
"base": "PersistedModel",
"idInjection": true,
"options": {
"relations": {
"chatMessages": {
"type": "hasMany",
"model": "ChatMessages",
"foreignKey": "chatMessagesID"
}
}
},
...
컨트롤러 6,
: 쌍방향 관계
function getMsgs() {
// http://loopback.io/doc/en/lb2/Include-filter.html
return (
ChatMessage.find({
"filter": {
"include": {
"relation": "chatroomID",
"scope": {
"include": ["ChatRoom"]
}
}
}
})
감사합니다. "채팅 메시지가 요청에 대해 처리되지 않았습니다. 필터가 % 7B % 22 포함되었습니다. 22 : % 7B % 22 응답 22 : % 22chatMessages % 22 % 7D % 7D : 오류 : 관계"chatMessages "가 아닙니다. ChatMessage 모델에 정의 됨 ' –
@NatuMyers 아 죄송합니다. 내 잘못이야. 호출 할 모델은'ChatMessage'가 아닌'ChatRoom'입니다. 나는 나의 대답을 업데이트했다. 그것이 잘못된 모델에서 호출 한 코드의 또 다른 문제점입니다. –
많이 고맙습니다 <3 –