mongodb - 执行 mgo.Pipe 没有结果,包括 $out

标签 mongodb go mgo

我正在尝试运行一个不返回任何结果的管道,因为最后一个管道运算符是 $out

// { $out: "y" } 
pipeline := DB. C("x"). Pipe(stages). AllowDiskUse() 
result := []bson.M{}
err := pipeline.All(&result) 

运行管道时出现超时。我假设 mgo 正在等待结果被读取——永远。

最佳答案

已解决。不要调用 All(&result),而是调用 Iter()

All 会在从一开始就为空的迭代器上调用 Next,显然会导致超时。

Iter 返回一个迭代器,它将被丢弃。没有调用 Next,没有超时。

关于mongodb - 执行 mgo.Pipe 没有结果,包括 $out,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49496003/

相关文章:

mongodb - MongoDB (WiredTiger) 返回的计数不正确

MySQL 密码 () 列 : migration to MongoDB

regex - 在Go中优化正则表达式的内存消耗

go - 在 .go 文件中运行函数和在 Go 模板中调用它有什么区别?

mongodb - 按 id 限制更新/查找

mongodb - 如何检查集合是否存在 MongoDB Golang

javascript - 查找过去 7 天当天的最后一份文件

mongodb - Meteor.js – 基于Session变量的$或mongodb查询

user-interface - GO GUI帮助(走包)

mongodb - 如何使用 MGO 聚合管道查找符合特定条件的所有嵌入文档