-
Notifications
You must be signed in to change notification settings - Fork 4
[Feat] 질문지 조회 기능에 Pagination 구현 #254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feat] 질문지 조회 기능에 Pagination 구현 #254
Conversation
yiseungyun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
맞아요. 시간이 부족할 땐 일단 라이브러리를 사용하는게 좋은 선택 같습니다!
나중에 라이브러리가 불편하거나 안 좋은 점이 있다면 바꿔도 되니까요.
수고하셨습니당. 수민뭼. 👍
blu3fishez
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pagination 적용하신게 대부분이고, 리팩토링도 잘 되어가시는 것 같아서 보기 좋습니다!
끝까지 화이팅입니다~!
| return this.dataSource | ||
| .getRepository(QuestionList) | ||
| .createQueryBuilder("question_list") | ||
| .where("question_list.is_public = :isPublic", { isPublic: true }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 코드 보면서 느끼는건데, ORM 쓰길 엄청 잘했다고 생각듭니다 ㅋㅋ 코드가 엄청 깔끔하네요
| return this.dataSource.getRepository(QuestionList).find({ | ||
| where: { | ||
| isPublic: true, | ||
| categories: { id: categoryId }, | ||
| }, | ||
| relations: ["categories"], | ||
| }); | ||
| return this.dataSource | ||
| .getRepository(QuestionList) | ||
| .createQueryBuilder("question_list") | ||
| .innerJoin("question_list.categories", "category") | ||
| .where("question_list.is_public = :isPublic", { isPublic: true }) | ||
| .andWhere("category.id = :categoryId", { categoryId }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
깔끔하게 리팩토링 된 것 같아서 좋습니다! 쿼리빌더 이제 잘 활용하시는 것 같아서� 같은 백엔드 개발자로써 뿌듯하네용 ㅎㅎㅎ
| const result = await paginate(query, publicQuestionLists, { | ||
| sortableColumns: ["usage"], | ||
| defaultSortBy: [["usage", "DESC"]], | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sort 기준과 기본 sort 기준까지.. 괜찮네요! 이부분 나중에 enum으로 리팩토링 해보시겠다고 하셨는데 이쪽에서도 활용해보시면 괜찮을 것 같네요!
ShipFriend0516
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
페이지네이션 어려운 부분이었을텐데 고생하셨습니다
6주 끝나고 바꿔보는 것도..?ㅎㅎㅎ
Note
✅ 체크리스트
🧩 작업 내용
nestjs-paginate라이브러리 설치📝 작업 상세 내역
nestjs-paginate라이브러리 설치nestjs-paginate을 선택했습니다.nestjs-typeorm-paginate라는 라이브러리도 있었지만, typeorm에 종속되는 라이브러리이며 비교적 사용 방법이 복잡해서nestjs-paginate을 선택했습니다.pagination 구현
📌 테스트 및 검증 결과
💬 다음 작업 또는 논의 사항
📎 참고 자료