gpt4 book ai didi

mongodb - 在 Mongo 中,我如何漂亮地打印结果,所以 .find() 看起来像 .findOne()

转载 作者:IT老高 更新时间:2023-10-28 11:14:22 30 4
gpt4 key购买 nike

findOne() 生成 pretty-print 的 json 对象。

find() 导致 json 对象乱码。

在 mongo shell 中显示时,如何使 find()findOne() 相同?

最佳答案

如果您使用 javascript 编写脚本,则可以使用 dcrosta 的答案。但是如果你想直接在 mongo 交互式 shell 上进行 pretty-print ,你必须将 pretty() 附加到你的 find() 查询中。

在外壳上键入:db.yourcollection.find().pretty()

关于mongodb - 在 Mongo 中,我如何漂亮地打印结果,所以 .find() 看起来像 .findOne(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6756024/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com