-
Type: Task
-
Resolution: Done
-
Priority: Trivial - P5
-
Affects Version/s: None
-
Component/s: manual
-
Labels:
-
Environment:
*Location*: http://docs.mongodb.org/manual/reference/program/mongoexport/
*User-Agent*: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36
*Referrer*: http://docs.mongodb.org/manual/search/?query=mongoexport
*Screen Resolution*: 1280 x 800
*repo*: docs
*source*: reference/program/mongoexport
*Location*: http://docs.mongodb.org/manual/reference/program/mongoexport/ *User-Agent*: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36 *Referrer*: http://docs.mongodb.org/manual/search/?query=mongoexport *Screen Resolution*: 1280 x 800 *repo*: docs *source*: reference/program/mongoexport
It would help if we can add an example on how to export sub documents in an array.
For example, if we have a document like this:
{ "_id" : ObjectId("527b09b18c6f25a12b5aadb6"), "a" : { "b" : [ { "c" : 2 }, { "c" : 3 } ] } }
To export the first element of array b, use āa.b.0ā as the field name:
mongoexport -d <database> -c <collection> -f "a.b.0"
To export the value of c in the first element of array b, use āa.b.0.cā as the field name:
mongoexport -d <database> -c <collection> -f "a.b.0.c"