I have recently started developing a project using C++11 and MongoDb, although i have successfully used mongocxx driver to implement the logic, but it takes some time to desiralize the data.
mongocxx::options::find opts;
opts.limit(15000);
mongocxx::cursor cursor = collection.find({},opts);
for(auto && doc : cursor) {
bsoncxx::document::element name = doc["Name"];
bsoncxx::document::element experience = doc["Experience"];
bsoncxx::document::element jobTitle = experience["JobTitle"];
bsoncxx::document::element keywords = experience["Keywords"];
string name = name.get_utf8().value.to_string();
string jobTitleStr = jobTitle.get_utf8().value.to_string();
bsoncxx::array::view keyWordsarray{keywords.get_array()};
set<string> keyWordsSet;
for (bsoncxx::array::element msg : keyWordsarray) {
keyWordsSet.insert(msg.get_utf8().value.to_string());
}
}
The above operation takes 1.5 seconds for me. I was hoping is there any ODM present in C++ for mongoDb (like mongoengine in Python) to take care of the deserialization work.
You should have a look at mangrove: https://github.com/mongodb-labs/mangrove
It is a mongodb-labs project, so, not officially supported, but it might show you how to approach building your own object document mapping above mongocxx.