本文介绍了在 mongodb shell 中打印文档值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 mongo shell 中打印此 JSON 文档的值.就像一个简单的控制台输出,无需创建新的集合或文档.
I want to print the value for this JSON document in the mongo shell. Like a simple console output, without creating a new collection or document.
提前致谢
推荐答案我找到了一个解决方案,通过使用 .forEach() 来应用一个 JavaScript 方法:
I found a solution, by using .forEach() to apply a JavaScript method:
db.widget.find( { id : "4" }, {quality_level: 1, _id:0} ).forEach(function(x) { print(x.quality_level); });更多推荐
在 mongodb shell 中打印文档值
发布评论