codestates / codestates/AnimalChat

[Error Handling👾] this.sourceKeyField = this.source.rawAttributes[this.sourceKey].field || this.sourceKey; ^ TypeError: Cannot read properties of undefined (reading 'field')

Open
#199 0 comments 0 reactions 0 assignees View on GitHub
error
Dominant language
JavaScript
Stars
0
Forks
3
PR merge metrics
No merged PRs in 30d

Description

## 어떤 에러인가요?
- hasMany 관계일 때 관계 설정 오류

## 에러 메시지
```jsx
this.sourceKeyField = this.source.rawAttributes[this.sourceKey].field || this.sourceKey;
^
TypeError: Cannot read properties of undefined (reading 'field')
```

## 에러 핸들링 방법
- 핸들링 방법에 대해 글이나 코드로 작성해주세요.
```jsx
belongsTo관계일 때로 착각해서 포린키와 소스키를 반대로 썼었다. 다시 아래처럼 수정함.
models.comment.hasMany(models.like, {foreignKey: "comment_id", sourceKey: "id"})
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.