-
Notifications
You must be signed in to change notification settings - Fork 0
엔티티 리팩터링 갈무리 #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
엔티티 리팩터링 갈무리 #25
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,23 @@ | ||
## 업데이트 유형 | ||
|
||
- [ ] Hot Fix | ||
- [ ] Release | ||
- [ ] Develop | ||
- [ ] Others | ||
|
||
## 업데이트 개요 | ||
|
||
* Fix # (issue) | ||
* Feature # (issue) | ||
[여기에 PR 한줄 요약 작성, 대상 이슈번호 작성.] | ||
|
||
[여기에 PR 한줄 요약 작성, 대상 이슈번호 작성.] | ||
|
||
## 업데이트 요약 | ||
업데이트 내역 작성 | ||
|
||
## 새로운 정책 | ||
세부 변경 사항 작성 | ||
|
||
## 해결한 문제 | ||
해결한 문제 등 이슈 | ||
|
||
## 미해결 문제 | ||
미해결 이슈, 발견한 이슈 | ||
|
||
## 테스트 | ||
- [ ] 유닛 테스트 | ||
- [ ] 빌드 테스트 (통합 테스트) | ||
- [ ] 기타 유효성 테스트 | ||
업데이트 내역 작성 | ||
|
||
## 수정 사항 진단 | ||
|
||
- [ ] 코드가 이 프로젝트의 스타일 지침을 따릅니다. | ||
- [ ] 코드에 대한 자체 리뷰를 수행했습니다. | ||
- [ ] 변경 내역에 대해 주석을 작성했습니다. | ||
- [ ] 해당 PR에 대한 문서를 변경했습니다. | ||
- [ ] 기능, 정책, 수정 사항, 이슈에 대한 테스트 코드를 추가했습니다. | ||
- [ ] 변경 내용이 로컬 개발환경에서의 테스트를 통과했습니다. | ||
- [ ] 모든 종속 변경 사항이 병합되어 다운스트림 모듈에 게시되었습니다. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,31 @@ | ||
import { Prop, SchemaFactory } from '@nestjs/mongoose'; | ||
import { IsMongoId, IsString } from 'class-validator'; | ||
import { ObjectId } from 'mongodb'; | ||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | ||
import { HydratedDocument } from 'mongoose'; | ||
|
||
export type GroupDocument = HydratedDocument<Group>; | ||
|
||
@Schema() | ||
export class Group { | ||
@Prop({ type: ObjectId }) | ||
@IsMongoId() | ||
id: string; | ||
|
||
@Prop({ required: true }) | ||
@IsString() | ||
name: string; | ||
|
||
@Prop() | ||
@IsString() | ||
description: string; | ||
|
||
@Prop({ type: [String], ref: 'Poker' }) | ||
pokers: string[]; | ||
|
||
constructor(id: string, name: string, description: string, pokers: string[]) { | ||
this.id = id; | ||
this.name = name; | ||
this.description = description; | ||
this.pokers = pokers; | ||
} | ||
|
||
static fromDocument(groupDocument: GroupDocument): Group { | ||
return new Group(groupDocument._id.toString(), groupDocument.name, groupDocument.description, groupDocument.pokers); | ||
} | ||
} | ||
|
||
export const GroupSchema = SchemaFactory.createForClass(Group); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,56 @@ | ||
import { SchemaFactory } from '@nestjs/mongoose'; | ||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | ||
import { HydratedDocument } from 'mongoose'; | ||
|
||
import { Problem } from './problem.entity'; | ||
|
||
export type ParticipantDocument = HydratedDocument<Participant>; | ||
|
||
@Schema() | ||
export class Participant { | ||
@Prop({ required: true }) | ||
handle: string; | ||
|
||
@Prop({ required: true }) | ||
profileImage: string; | ||
|
||
@Prop({ required: true }) | ||
snapshot: number[]; | ||
|
||
@Prop({ required: true }) | ||
point: number; | ||
|
||
@Prop({ required: true }) | ||
goal: number; | ||
|
||
@Prop({ required: true }) | ||
result: Problem[]; | ||
|
||
constructor( | ||
handle: string, | ||
profileImage: string, | ||
snapshot: number[], | ||
point: number, | ||
goal: number, | ||
result: Problem[], | ||
) { | ||
this.handle = handle; | ||
this.profileImage = profileImage; | ||
this.snapshot = snapshot; | ||
this.point = point; | ||
this.goal = goal; | ||
this.result = result; | ||
} | ||
|
||
static fromDocument(participantDocument: ParticipantDocument): Participant { | ||
return new Participant( | ||
participantDocument.handle, | ||
participantDocument.profileImage, | ||
participantDocument.snapshot, | ||
participantDocument.point, | ||
participantDocument.goal, | ||
participantDocument.result, | ||
); | ||
} | ||
} | ||
|
||
export const ParticipantSchema = SchemaFactory.createForClass(Participant); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.
Copilot uses AI. Check for mistakes.