如何在mongoDB中對(duì)集合記錄中的數(shù)組進(jìn)行排序MongoDB noob在這里......好的,我有一個(gè)學(xué)生集合,每個(gè)都有一個(gè)如下所示的記錄....我想按照降序排序'類型':'家庭作業(yè)'分?jǐn)?shù)。那個(gè)咒語在mongo shell上是什么樣的?> 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
}
]}我正在嘗試這個(gè)咒語.... doc = db.students.find()
for (_id,score) in doc.scores:
print _id,score但它不起作用。
如何在mongoDB中對(duì)集合記錄中的數(shù)組進(jìn)行排序
郎朗坤
2019-07-24 20:09:47