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

Upgrading MongoDB C++ Driver to mongocxx-3.1.2

本文关键字:mongocxx-3 MongoDB C++ 驱动程序      更新时间:2023-10-16

如何轻松地从 mongoDB C++ 驱动程序从 Legacy 升级到 mongocxx-3.1.2? mongocxx-3.1.2 中有哪些类可以遵循?

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

提前感谢..

没有"升级" - 库提供完全不同的 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.