![](/img/trans.png)
[英]Mongo Db Query to sort by the field and also aggregate the results which do not have that field
[英]How to sort mongo aggregate query based on results inner object
如果mongo聚合結果為:
{
_id : "5c1a39d182ceb728c3430275",
docs : {
"First Name": "Nilesh",
"Last Name" : "Sodha",
"Age" : 23
}
},
{
_id : "5c1a39d182ceb728c3430274",
docs : {
"First Name": "Pradip",
"Last Name" : "Sodha",
"Age" : 25
}
}
如何在JAVA中基於“年齡”獲得排序結果
嘗試這個
mongoTemplate.find(new Query(Criteria.where("_id").is(mongoId))
.with(new Sort(Sort.Direction.DESC, "Age")), eClass);
mongoId =自動生成的mongo id
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.