I'm just learning about MongoDB. Is there an easy way to export/import data from MongoDB?
The task at hand is simple: Using MongoDB Cloud, copy a document from a collection (using the Copy Document button located in the Atlas > Collection section) and be able to import it into my local MongoDB DB. Doing so, I got the following:
{
"_id": {"$oid":"5e666e346e781e0b34864de4"},
"created_at":{"$date":{"$numberLong":"1583771188026"}}
}
Trying to import that into my local MongoDB using db.my_collection.insert()
leads me to the following error:
WriteResult({
"nInserted" : 0,
"writeError" : {
"code" : 52,
"errmsg" : "$oid is not valid for storage."
}
})
So I've already done my research and I've found about how MongoDB creates output data in Extended JSON v2.0 (Relaxed mode) by default or in Canonical Mode.
So the documentation is really telling me the format that is used to export in MongoDB is not natively supported to be able to directly import it? What did I get wrong?
How can I import directly what is being exported?