[DOCS-2204] Add exporting subdocument example to mongoexport Created: 07/Nov/13  Updated: 30/Oct/23  Resolved: 15/Aug/16

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Improvement Priority: Trivial - P5
Reporter: Linda Qin Assignee: Allison Reinheimer Moore
Resolution: Done Votes: 0
Labels: collector-298ba4e7, tools
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
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


Issue Links:
Depends
Participants:
Days since reply: 7 years, 26 weeks, 2 days ago

 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"



 Comments   
Comment by Allison Reinheimer Moore [ 15/Aug/16 ]

This doesn't seem to work with the new toolchain. If this is closed in error, please open a new ticket!

Generated at Thu Feb 08 07:42:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.