3

I am trying to extract data from a query in Mongodb with nested items.

Example:

{ '_id': 1111,
  'identity': {
    'name': 'John'
    'surname': 'Doe'
   }
}

We need a query to extract all surnames into a CSV. So, as I'm using Robo 3T tool, I create the .robomongorc.js file as explained here: https://github.com/Studio3T/robomongo/wiki/How-to-export-to-CSV

And execute the following query:

db.collection.find({"identity.surname":1}).toCSV();

The results are like this:

"_id","identity"
"1111","[object BSON]"

How can I get the surname data as a string instead of this "[object BSON]"?

Belen
  • 673
  • 2
  • 10
  • 25

0 Answers0