codestates / codestates/BookDam
22.01.06 Dev-Log
- Dominant language
- JavaScript
- Stars
- 1
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
### 오늘은 어떻게 프로젝트에 기여했나요?
- follow 추가, 삭제 기능 구현
- 피드 페이지에서 이용될 article 조회 기능(유저가 follow한 사용자들의 article) 구현
- 네이버 도서 검색 api 구현
### 오늘의 프로젝트에서 힘든 점은 무엇인가요?
- follow한 사용자들의 article을 넘기는 과정에서 데이터를 정리하는 것에 어려움이 있었습니다.
```js
UserModel.findAll({
attributes: { exclude: ['updatedAt', 'createdAt', 'password'] },
include: [{ model: ArticleModel, attributes: { exclude: ['id', 'updatedAt'] } },
{ model: FollowModel, where: { user_Id: id }, attributes: { exclude: ['id', 'createdAt', 'updatedAt'] } }],
})
```
위의 코드로 작성을 했을 때 아래와 같은 형태로 출력이 되었습니다.
```js
[
{
"id": 2,
"userId": "test2",
"userNickName": "test2",
"userImage": "blahblahblahblah",
"Articles": [
{
"id": 5,
"user_Id": 2,
"book_Title": "파친코",
"book_Author": "미상",
"book_Thumbnail": "blahblahblahblah",
"book_Publisher": "미상",
"sentense": "blahblahblahblah",
"comment": "blahblahblahblah",
"createdAt": "2022-01-03",
"updatedAt": "2022-01-06T01:12:50.000Z"
},
],
"Follows": [
{
"id": 1,
"user_Id": 1,
"follow_Id": 2,
"createdAt": "2022-01-06T01:12:50.000Z",
"updatedAt": "2022-01-06T01:12:50.000Z"
}
]
}
]
```
위처럼 작성되는 데이터들을 Articles와 Follows를 풀어서 출력하길 원했고, raw 메소드를 넣어서 해결할 수 있었습니다.
```js
UserModel.findAll({
attributes: { exclude: ['updatedAt', 'createdAt', 'password'] },
include: [{ model: ArticleModel, attributes: { exclude: ['id', 'updatedAt'] } },
{ model: FollowModel, where: { user_Id: id }, attributes: { exclude: ['id', 'createdAt', 'updatedAt'] } }],
raw: true
})
```
```js
{
"id": 3,
"userId": "test3",
"userNickName": "test3",
"userImage": "blahblahblahblah",
"Articles.user_Id": 3,
"Articles.book_Title": "신데렐라",
"Articles.book_Author": "미상",
"Articles.book_Thumbnail": "blahblahblahblah",
"Articles.book_Publisher": "미상",
"Articles.sentense": "blahblahblahblah",
"Articles.comment": "blahblahblahblah",
"Articles.createdAt": "2022-01-01",
"Follows.user_Id": 1,
"Follows.follow_Id": 3
}
```
sequelize에 대해서 학습을 많이 했다고 생각을 했지만, 메소드에 대한 학습과 이해가 부족했던 거 같아 크게 아쉬웠습니다.
- 네이버 api 사용 예제를 보고 프로젝트에 반영하는 것에 어려움이 있었습니다.
지금 구현하긴 했지만, npm request 에 대해서 학습이 더 필요할 거 같습니다.
### 내일은 프로젝트에 기여하기 위해 무엇을 해야 하나요?
- [ ] article 수정, 삭제 기능을 구현할 것입니다.
- [ ] article 생성을 위해서 사진 데이터 저장하는 방법을 학습할 것입니다.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.