Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-2204

Add exporting subdocument example to mongoexport

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Trivial - P5
    • Resolution: Gone away
    • None
    • None
    • manual
    • Docs Sprint 2016(0711-0729)
    • true

    Description

      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"
      

      Attachments

        Activity

          People

            allison.moore@mongodb.com Allison Reinheimer Moore
            linda.qin@mongodb.com Linda Qin
            Jonathan Dahl Jonathan Dahl
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              5 years, 51 weeks, 5 days ago