在Mongo Atlas UI中使用聚合器
我正在使用UI中使用Mongo Atlas的总管道,并且可以将其钉住一点,但是我无法在特定领域进行区域。
我已经对其进行过滤直到现在,我只想将ID的区别作为列表,例如我们在SQL中获得的列表。
从表中选择不同的(id)。
orderReceivedBy: “something”
ID: 150435
country: “UAE”
createdAt: 2022-02-14T09:55:59.393+00:00
orderReceivedBy: “something”
ID: 150435
country: “IN”
createdAt: 2022-02-14T09:55:59.393+00:00
orderReceivedBy: “something”
ID: 150435
country: “NL”
createdAt: 2022-02-14T09:55:59.393+00:00
结果应为
UAE
IN
NL
I am using aggregate pipeline in mongo atlas, using UI, and I am able to nail down it a bit , however I am not able to do district on particular field.
I have filtered it until below now I want only distinct of ID as a list like how we get in sql.
select distinct(ID) from table.
orderReceivedBy: “something”
ID: 150435
country: “UAE”
createdAt: 2022-02-14T09:55:59.393+00:00
orderReceivedBy: “something”
ID: 150435
country: “IN”
createdAt: 2022-02-14T09:55:59.393+00:00
orderReceivedBy: “something”
ID: 150435
country: “NL”
createdAt: 2022-02-14T09:55:59.393+00:00
Result should be
UAE
IN
NL
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在聚合管道中获得唯一国家/地区的一种方法是使用
“ $ group”
阶段。示例输出:
尝试一下 mongoplayground.net.net 。
One way you can get the unique countries in an aggregation pipeline is by using a
"$group"
stage.Example output:
Try it on mongoplayground.net.