将MongoDB C ++驱动程序升级到mongocxx-3.1.2

时间:2017-07-26 07:16:15

标签: c++ mongodb bson mongo-cxx-driver

如何轻松地从mongoDB C ++驱动程序从Legacy升级到mongocxx-3.1.2? mongocxx-3.1.2中有哪些类用于跟随?

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

先谢谢..

1 个答案:

答案 0 :(得分:2)

没有"升级" - 图书馆提供完全不同的API。您需要重新编写与BSON或MongoDB交互的应用程序部分才能使用它(您还需要一个现代的C ++工具链)。

要了解您所询问类型的类似物,建议您阅读https://mongodb.github.io/mongo-cxx-driver/mongocxx-v3/working-with-bson/

此处提供了当前稳定版本库(3.1.2)的完整文档:https://mongodb.github.io/mongo-cxx-driver/api/current/

详细说明您请求的类型的映射:

  • mongo::BSONElement最接近的类似物为bsoncxx::document::element
  • mongo::BSONObj最接近的类似物是bsoncxx::document::value及其关联的视图类型bsoncxx::document::view
  • mongo::BSONObjBuilder最接近的类似物为bsoncxx::builder::basic::document