汇总可能会得到单个结果吗? [英] Is it possible to get single result in aggregate?
本文介绍了汇总可能会得到单个结果吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以像db.collection.findOne
一样在db.collection.aggregate
上获得单个文档?
Is it possible to get a single document on db.collection.aggregate
like as in db.collection.findOne
?
推荐答案
可以添加 $match
阶段到聚合管道.但是,即使仅匹配一个文档,结果仍将是一个列表(在这种情况下,长度为一个).因此答案是"否,这是不可能的".
It is possible to add $match
stage to aggregation pipeline. But even if it will match only one single document, then result will still be a list (of length one in that case). So the answer is "NO, it is not possible".
这篇关于汇总可能会得到单个结果吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文