Find() doesn't display 3rd level array element data, only show as [object]


I defined a collection with 3 level arrays. I’m able to insert value into the 3rd level array, but having trouble to view the inserted element value since find() always shows as [object] for the 3rd level array. Is this expected behavior in MongoDB? How can I display it to verify?


See example:
db.col_1.find({“tp_id”: “tp-1”},{“arr_1.t_period”:1, “arr_1.arr_2.txid”:1, “arr_1.arr_2.arr_3.OLIid”:1, _id:0});
arr_1: [
t_period: ‘2020’,
arr_2: [
{ txid: ‘tx1’, arr_3: [ [Object] ] },
{ txid: ‘tx2’, arr_3: }
t_period: ‘2021’,
arr_2: [ { txid: ‘tx1’ }, { txid: ‘tx2’, arr_3: } ]

Hi Linda,

Based on your question, I believe you are using mongosh to query data.

You will need to change the mongosh config file in order to print all the objects in a document for single line or Depth of the object.

The parameters are: InspectDepth and inspectCompact.

Please have a look on:

More info on the location of the config file is also in this link.