From the documentation, it says to avoid mongoexport on BSON datatypes
WARNING Avoid using mongoimport and mongoexport for full instance production backups. They do not reliably preserve all rich BSON data types, because JSON can only represent a subset of the types supported by BSON. Use mongodump and mongorestore as described in MongoDB Backup Methods for this kind of functionality.
Created a collection with name "testCollection"
> db.testCollection.insert({title: 'MongoDB Overview',
... description: 'MongoDB is magical database',
... by: 'by newbie',
... url: 'http://www.mongodb_cannot_understand_mongoexport.com',
... tags: ['mongodb', 'database', 'NoSQL'],
... likes: 100});
> db.testCollection.find().pretty();
{
"_id" : ObjectId("59524e6412d3ef3c879c267a"),
"title" : "MongoDB Overview",
"description" : "MongoDB is magical database",
"by" : "by newbie",
"url" : "http://www.mongodb_cannot_understand_mongoexport.com",
"tags" : [
"mongodb",
"database",
"NoSQL"
],
"likes" : 100
}
Executing the below commands gives type as object and String,
typeof db.testCollection.findOne()._id; output : object
typeof db.testCollection.findOne().title; output : string
If running mongoexport on the above collection may or mayn't guarantee the preservation of data as it contains the data types string and object. (I doubt any documents will not have string, objectID datatype)
In that case mongoexport should not be used at all from this list of bson types link description here
My question is
In what cases mongoexport can be used with a example collection ?
NOTE: I want to use mongoexport, mongodump is not an option