Skip to content

엔티티 리팩터링 갈무리 #25

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

Merged
merged 4 commits into from
Apr 5, 2025
Merged

엔티티 리팩터링 갈무리 #25

merged 4 commits into from
Apr 5, 2025

Conversation

w8385
Copy link
Member

@w8385 w8385 commented Apr 5, 2025

업데이트 유형

  • Hot Fix
  • Release
  • Develop
  • Others

업데이트 개요

엔티티 구조가 완전하지 않았음
해당 구조 리팩터링에 집중

업데이트 요약

  • NestJS에서 권장하는 방식으로 엔티티 구조 갈무리
    • @Schema 클래스
    • export type Document (mongoose)
    • SchemaFactory
  • 개발 편의를 위한 팩토리 메서드
  • constructor
  • static fromDocument

수정 사항 진단

  • 코드가 이 프로젝트의 스타일 지침을 따릅니다.
  • 코드에 대한 자체 리뷰를 수행했습니다.
  • 기능, 정책, 수정 사항, 이슈에 대한 테스트 코드를 추가했습니다.
  • 변경 내용이 로컬 개발환경에서의 테스트를 통과했습니다.

@w8385 w8385 requested a review from Copilot April 5, 2025 15:10
@w8385 w8385 self-assigned this Apr 5, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

@@ -40,7 +40,7 @@ export class ProblemService {
.then((res) => res.data);

for (const problem of response['items']) {
problems.push(new Problem(problem));
problems.push(problem);
Copy link
Preview

Copilot AI Apr 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the instantiation (i.e., new Problem(problem)) may lead to inconsistent behavior if consumers expect an instance with methods defined on the Problem class. Consider converting the raw problem object to a Problem instance using Problem.fromDocument or the appropriate constructor.

Suggested change
problems.push(problem);
problems.push(new Problem(problem));

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validate(id: string, poker: Poker): void {
if (!poker) {
async update(id: string, poker: Poker): Promise<Poker> {
const pokerDoc = await this.pokerModel.findByIdAndUpdate(id, poker);
Copy link
Preview

Copilot AI Apr 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

findByIdAndUpdate by default returns the pre-update document. Consider adding the option { new: true } to return the updated document, ensuring that Poker.fromDocument reflects the latest changes.

Suggested change
const pokerDoc = await this.pokerModel.findByIdAndUpdate(id, poker);
const pokerDoc = await this.pokerModel.findByIdAndUpdate(id, poker, { new: true });

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

@w8385 w8385 merged commit 976e94a into dev Apr 5, 2025
1 check passed
@w8385 w8385 deleted the refactor/entity branch April 5, 2025 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant