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

Add exporting subdocument example to mongoexport

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Trivial - P5 Trivial - P5
    • Server_Docs_20231030
    • Affects Version/s: None
    • Component/s: manual
    • Environment:

      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"
      

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

              Created:
              Updated:
              Resolved:
              7 years, 37 weeks ago