2

How to upgrade from mongoDB C++ driver from Legacy to mongocxx-3.1.2 easly? What are the classes in mongocxx-3.1.2 for following?

mongo::BSONElement;
mongo::BSONObj;
mongo::BSONObjBuilder;

Thanks In Advance..

snb
  • 633
  • 1
  • 6
  • 13

1 Answers1

2

There is no "upgrade" - the libraries offer entirely different APIs. You will need to re-write the parts of your application that interact with BSON or MongoDB in order to use it (you will also need a modern C++ toolchain).

To understand the analogues for the types you are asking about, I recommend reading https://mongodb.github.io/mongo-cxx-driver/mongocxx-v3/working-with-bson/

Complete documentation for the current stable version of the library (3.1.2) is available here: https://mongodb.github.io/mongo-cxx-driver/api/current/

To elaborate a bit on the mappings of the types you requested:

  • The closest analogue to mongo::BSONElement is bsoncxx::document::element
  • The closest analogue to mongo::BSONObj is bsoncxx::document::value and its associated view type bsoncxx::document::view.
  • The closest analogue to mongo::BSONObjBuilder is bsoncxx::builder::basic::document.
acm
  • 12,183
  • 5
  • 39
  • 68