为什么 mongoDB 中的 pretty()
不支持 findOne()
。
db.collection.find().pretty()
是可以接受的,但 db.collection.findOne().pretty()
是不可接受的。任何原因?。有人会说 findOne() 已经以漂亮的格式打印,所以需要再次调用 pretty() ,但关键是为什么 mongoDB 不支持它,因为它只是一个以漂亮格式打印/显示结果的函数。请告诉我为什么在 mongoDB 中不允许这样做。
编辑:
我只是观察到,如果集合为空,db.collection.find()
将不返回任何内容,而 db.collection.findOne()
将返回 null。为什么会这样?