Reputation: 11
I have a few bson files which i need to insert into the mongodb using c++ code. Is there any way to insert a bson document into mongodb using mongocxx driver? I am using ubuntu, and all I could get was to manually create the document inside the code.
Upvotes: 1
Views: 148
Reputation: 188
MongoDB doesn't have an API to manipulate BSON files, so you'll need to use an external tool:
mongorestore
to import your BSON files, you can launch it from your C++ code using exec
or alike functions.bsondump
to create a JSON file from your BSON file and then insert it using the C++ driver, but as mentioned on the doc page: bsondump is a diagnostic tool for inspecting BSON files, not a tool for data ingestion or other application use.
Upvotes: 1