Lesson 4: Data Export Tools / Learn
Code Summary: Data Export Tools
Review the following code, which demonstrates how to use the mongoexport tool.
The following command exports documents from the transactions collection in the sample_training database running on the cluster at the URI "mongodb+srv://dbaTestAdmin@cluster1.xwgj1.mongodb.net/". The exported documents contain a field transaction_count where the value is greater than or equal to 50. The documents are exported to a file named export.json in canonical JSON format.
mongoexport \
-v \
--collection transactions \
--query '{"transaction_count": {"$gte": 50}}'
--out export.json \
--jsonFormat canonical \
"mongodb+srv://dbaTestAdmin@cluster1.xwgj1.mongodb.net/sample_analytics”
The following options can be used with the mongoexport command. Check out the MongoDB documentation for more information.
--collection
--type
--out
--jsonFormat
--query