在 mongodb shell 中打印文档值

编程入门 行业动态 更新时间:2024-10-23 08:35:12
本文介绍了在 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 中打印文档值

本文发布于:2023-11-22 18:36:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1618544.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文档   mongodb   shell

发布评论

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

>www.elefans.com

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