scores
生徒のコレクションがあり、それぞれに次のようなレコードがあり、配列を の降順で並べ替えたいと考えていますscore
。
その呪文はモンゴシェルでどのように見えますか?
> db.students.find({'_id': 1}).pretty()
{
"_id" : 1,
"name" : "Aurelia Menendez",
"scores" : [
{
"type" : "exam",
"score" : 60.06045071030959
},
{
"type" : "quiz",
"score" : 52.79790691903873
},
{
"type" : "homework",
"score" : 71.76133439165544
},
{
"type" : "homework",
"score" : 34.85718117893772
}
]
}
私はこの呪文を試しています....
doc = db.students.find()
for (_id,score) in doc.scores:
print _id,score
しかし、それは機能していません。