I am trying to get CSV from mongo-db using mongoexport.
My data in this format:
{
"_id": "99",
"page_id": NumberLong(1122334455),
"data": {
"0": {
"item_id": NumberLong(123456789),
"item_name": "item1"
},
"1": {
"item_id": NumberLong(987654321),
"item_name": "item2"
},
},
"last_updated_utc": ISODate("2013-12-19T13:17:43.994Z")
}
To do this, I use the following command:
mongoexport -f _id,page_id,last_updated_utc --query {page_id:1122334455} -d mydatabase -c mycollection --csv
This gives the result:
"99",1122334455,2013-12-19T13:17:43.994Z
exported 1 record
The problem is that I need an element item_namefrom the dataelements in the output. This is a dynamic array that cannot contain elements or many elements.
If I add datafields (-f) to the parameter, it will simply output it as a JSON string in CSV for each object, which will not help to use the data in the future.
What I'm going to get is something like:
"99",1122334455,2013-12-19T13:17:43.994Z,item1
"99",1122334455,2013-12-19T13:17:43.994Z,item2
Almost denormalized or similar to an outer join in SQL. So its just element identifiers data.
Is it possible? How can I get item_idCSV output?