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

Add exporting subdocument example to mongoexport

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Trivial - P5
    • Resolution: Gone away
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: manual
    • Environment:
    • # Replies:
      1
    • Last comment by Customer:
      true
    • Sprint:
      Docs Sprint 2016(0711-0729)

      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

            Assignee:
            allison.moore Allison Reinheimer Moore
            Reporter:
            linda.qin Linda Qin
            Participants:
            Last commenter:
            Jonathan Dahl
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since reply:
              4 years, 4 days ago
              Date of 1st Reply: