Mongodb shell collapses nested documents/arrays in output -> how to uncollapse?

From a certain level of nesting, the mongodb shell collapses nested documents and arrays by default in the output. I cannot find a way to uncollapse this, so I can see the entire document.

For example:

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] } } }
      }
    }
  }
]

Notice the third document in the response: the sixth nested object is collapsed to ‘[Object]’

You can configure mongosh for how deep it expands arrays and nested objects. See inspectDepth here: https://docs.mongodb.com/mongodb-shell/reference/configure-shell-settings/#configurable-settings

3 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.