所以我使用了Map-Reduce范例来操作MongoDB集合并收到了以下输出:
/* 1 */
{
"results" : [
{
"_id" : "B00000IKQD",
"value" : 4.0
}
],
"timeMillis" : 14.0,
"counts" : {
"input" : 3,
"emit" : 3,
"reduce" : 1,
"output" : 1
},
"ok" : 1.0,
"_o" : {
"results" : [
{
"_id" : "B00000IKQD",
"value" : 4.0
}
],
"timeMillis" : 14,
"counts" : {
"input" : 3,
"emit" : 3,
"reduce" : 1,
"output" : 1
},
"ok" : 1.0
},
"_keys" : [
"results",
"timeMillis",
"counts",
"ok"
],
"_db" : {
"_mongo" : {
"slaveOk" : true,
"host" : "localhost:27017",
"defaultDB" : "test",
"_readMode" : "commands"
},
"_name" : "vg"
}
}
所以我在第一个数组“results”中得到它,它显示了我请求的输出,但之后有很多处理过的代码。
另外,有没有办法在输出中隐藏所有这些?
编辑:
所以基于@AlexBlex的回答,我刚刚添加了'.results'作为操作的结束(这样做很好):
db.P14165162_reviews.mapReduce(x, reduce,{
out:{inline:1},
query:{mts_asin:"B00000IKQD"},
}).results;
答案 0 :(得分:1)
输出记录在https://docs.mongodb.com/manual/reference/command/mapReduce/#output
To"隐藏所有这些"你只能返回结果:
db.collection.mapReduce(......).results