4

The MongoDB Shell (mongosh) collapses nested documents/arrays from a certain nesting depth by default. This makes viewing a document in its entirety impossible. Is there any way to uncollapse these without using an elaborate aggregation/projection?

For example:

DOCDB PROD>db.test.find()
[
  {
    _id: ObjectId("62330fc76bbaaf29df9ca461"),
    one: {
      two: { three: { four: { foo: 'bar' } } }
    }
  },
  {
    _id: ObjectId("62330fd76bbaaf29df9ca462"),
    one: {
      two: {
        three: { four: { five: { foo: 'bar' } } }
      }
    }
  },
  {
    _id: ObjectId("62330fe96bbaaf29df9ca463"),
    one: {
      two: {
        three: { four: { five: { six: [Object] } } }
      }
    }
  }
]

The third result has the nested object collapsed to [Object] instead of printing {foo:'bar'}

P. Drijkoningen
  • 235
  • 1
  • 7

1 Answers1

4

I found the answer here: https://docs.mongodb.com/mongodb-shell/reference/configure-shell-settings/

It is possible to fix this using the inspectDepth configuration setting.

P. Drijkoningen
  • 235
  • 1
  • 7