pymongo聚合不允许解释选项

编程入门 行业动态 更新时间:2024-10-27 10:28:54
本文介绍了pymongo聚合不允许解释选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我成功运行:

result = my_col.aggregate(my_pipeline, allowDiskUse=True)

现在,当我尝试:

result = my_col.aggregate(my_pipeline, allowDiskUse=True, explain=True)

它没有说:

pymongo.errors.ConfigurationError: The explain option is not supported. Use Databasemand instead.

因此,我尝试添加所需的选项:

Thus I try so as to add the needed option:

result = mydbmand('aggregate', 'mycol', my_pipeline, {'explain':True})

但没有说:

pymongo.errors.OperationFailure: 'pipeline' option must be specified as an array

怎么了?

谢谢您的建议.

基督徒

推荐答案

使用"pipeline"关键字参数将管道传递给"command":

Pass your pipeline using the "pipeline" keyword argument to "command":

dbmand('aggregate', 'mycol', pipeline=my_pipeline, explain=True)

例如:

dbmand('aggregate', 'mycol', pipeline=[{'$project': {'name': '$field'}}], explain=True)

更多推荐

pymongo聚合不允许解释选项

本文发布于:2023-10-23 04:24:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1519776.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不允许   选项   pymongo

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!