Skip to content

Instantly share code, notes, and snippets.

@ppillip
Created September 1, 2013 06:34
Show Gist options
  • Save ppillip/6402709 to your computer and use it in GitHub Desktop.
Save ppillip/6402709 to your computer and use it in GitHub Desktop.
3주차 콘솔에서 바로 실행하는 방법 scores 배열안에 순서가 보장된다는 전제 입니다. 그렇지 않다면 type 이 homework 인 넘의 index 부터 찾아야겠지요? ㅋ
db.students.find({}).forEach(function(a){
if(a.scores[2].score > a.scores[3].score){
a.scores.splice(3,1);
}else{
a.scores.splice(2,1);
}
db.students.save(a);
}
@baeminsik
Copy link

scores 배열 2,3 번 type이 homework 라고 되어있다고 전제!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment