MongoDB:如何“统一所有"用户来自同一馆藏的结果? [英] MongoDB: How to "union all" results from same collection?
本文介绍了MongoDB:如何“统一所有"用户来自同一馆藏的结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
query.1:
db.test.find({category_id:1}).sort({createAt:-1}).limit(5);
query.2:
db.test.find({category_id:2}).sort({createAt:-1}).limit(5);
我想要的是使用一个查询获取query1 + query2的结果,然后按createAt
对结果进行排序.
What I want is use one query get results of query1+query2, and then sort the results by createAt
.
推荐答案
查看全文