Skip to content

Feature/api read#1

Merged
nemo0824 merged 9 commits intomainfrom
feature/api-read
Feb 8, 2025
Merged

Feature/api read#1
nemo0824 merged 9 commits intomainfrom
feature/api-read

Conversation

@nemo0824
Copy link
Collaborator

@nemo0824 nemo0824 commented Feb 7, 2025

feature: uuid 형식으로 id 형식변경, 전체퀴즈목록 조회(id, title), 한문제씩 퀴즈문제 조회.

Comment on lines 117 to 123
for (const quiz of quizzes) {
const quizId = v4();
await Quiz.findOneAndUpdate(
{ id: quiz.id },
{ $setOnInsert: quiz },
{ id: quizId },
{ $setOnInsert: { ...quiz, id: quizId } },
{ upsert: true, new: true }
);
Copy link

Choose a reason for hiding this comment

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

왜 스트링 숫자로 만들고 upsert를 하나요? id를 처음부터 uuid로 만들면 되지 않나요?

answer: 'Hello, world!',
hint: '코드를 작성하고 결과를 확인하세요.',
description: '목표 지점까지 이동한 후 공격하세요.',
order: 1,
Copy link

Choose a reason for hiding this comment

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

이런 인덱스는 보통 0에서 시작하는 게 자연스럽습니다.

Copy link

Choose a reason for hiding this comment

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

저라면 nextId, previousId를 관리했을 것 같아요.
퀴즈가 1000개라고 할 때 첫 번째 퀴즈를 바꾼다면 기존 퀴즈 1000개의 order를 전부 바꿔야 하는데 링크드리스트 형태로 관리하면 가리키는 아이디만 바꾸면 되니까요.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 8, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
29.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Copy link

@new-deni new-deni left a comment

Choose a reason for hiding this comment

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

훨씬 자연스러워졌네요.
isFirst 필드를 만드는 것도 유효하지만 도큐먼트 하나 빼곤 모두 false일 테니 첫 번째 퀴즈 아이디를 들고 있는 테이블(컬렉션)을 만드는 방법도 괜찮았을 것 같아요. 참고만 하세요~

@nemo0824 nemo0824 merged commit 6b638fa into main Feb 8, 2025
1 of 2 checks passed
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.

2 participants