我有一个具有以下结构的mobgo文档。我需要在" sort_this"内进行搜索和排序。并返回排序" sort_this"只要。这可能是使用任何聚合函数或最佳方法吗?
{
"_id" : 4,
"sort_this" : [
{
"type" : "exam",
"score" : 60
},
{
"type" : "quiz",
"score" : 50
},
{
"type" : "homework",
"score" : 70
},
{
"type" : "homework",
"score" : 35
}
]
}
预期产出:
如果我搜索type =" homework"并希望按升序对结果进行排序,预期输出为
[{
"type": "homework",
"score": 35
},
{
"type": "homework",
"score": 70
}]