mongodb - MongoDB 和 Robo 3T - 错误“无法将 mapReduce 结果输出到内部数据库管理员”/“Location31321”
问题描述
我目前正在学习如何处理 MongoDB。
不幸的是,我无法执行 mapReduce 函数,而且我绝对没有找到有关该错误的任何信息:
errmsg:“无法将 mapReduce 结果输出到内部数据库管理员”
代号:“位置31321”
有没有人知道我可以做些什么来解决这个问题?
这是我的代码(我的同事对此没有任何问题):
db.courses.mapReduce(
function(){emit(this.course, this.hours);},
function(key, hours) {return Array.sum(hours)},
{
query: {semester: 1},
out: "totals"
}
)
db.totals.find()
提前非常感谢!
解决方案
我有同样的错误。我没有做“使用管理员”,而是切换到另一个名称的数据库,它对我有用。
使用“使用管理员”:
> db.Eleves.mapReduce(map, reduce, {out : "total_masculin"});
Error: map reduce failed:{
"ok" : 0,
"errmsg" : "Can't output mapReduce results to internal DB admin",
"code" : 31321,
"codeName" : "Location31321"
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DBCollection.prototype.mapReduce@src/mongo/shell/collection.js:1093:15
@(shell):1:1
切换数据库:
> use labo1
switched to db labo1
在这个数据库中重新创建我的集合之后:
> db.Eleves.mapReduce(map, reduce, {out : "total_masculin"});
{ "result" : "total_masculin", "ok" : 1 }
推荐阅读
- javascript - 如何防止广告网络在 Javascript 中重定向用户
- azure - 如果 azure VM 空闲 30 分钟,我需要将其关闭
- c# - GridView 覆盖行
- python - cython失败还是我做错了?
- ios - Websocket 和 WebRTC 在 iOS Swift 5 中处于后台时断开连接
- reactjs - 如何使用 ionic v4 添加自定义 webpack 配置并做出反应?
- c# - 无法加载文件或程序集......但不是一开始?
- python - 在 Python 或 C++ 中删除 K -Means 聚类/的背景掩码
- python - 用另一个字符替换一个字符序列
- javascript - React 和 Material UI:如何仅扩展一张卡片