美文网首页
mongo array sort

mongo array sort

作者: 马利杰 | 来源:发表于2018-08-14 20:18 被阅读0次

mongo数据记录

[

    {"id":1, "score":[100, 90]},

    {"id":1, "score":[100, 100]},

    {"id":1, "score":[100, 80]}

]

现在需要按照score的第二个值排序

db.getCollection('test').find({}).sort({"score.1":-1})

相关文章

网友评论

      本文标题:mongo array sort

      本文链接:https://www.haomeiwen.com/subject/ytkbbftx.html