Mongodb c ++驱动程序问题

Mongodb c++ driver issue

本文关键字:问题 驱动程序 Mongodb      更新时间:2023-10-16

我收到一个错误,说命名空间"bsoncxx::v_noabi::builder::basic"没有成员"make_document",我已经按照教程中提到添加了必需的包含。

我正在使用mongo-cxx-driver-r3.1.1版本。我从这里开始效仿

这是我尝试过的

       #include "maxi.h"
       #include <cstdlib>
       #include <iostream>
       #include <bsoncxx/builder/basic/array.hpp>
       #include <bsoncxx/builder/basic/document.hpp>
       #include <bsoncxx/builder/basic/kvp.hpp>
       #include <mongocxx/client.hpp>
       #include <mongocxx/instance.hpp>
    using bsoncxx::builder::basic::kvp;
    using bsoncxx::builder::basic::make_document;// here is error 
    using bsoncxx::type;
    mongocxx::instance inst{};
    mongocxx::client conn{ mongocxx::uri{ "mongodb://localhost:27017" } };

见图片

这里

我已经在编译后测试了MongoDB驱动程序,并且它运行良好。出于某种原因,我需要使用make_document选项来实现我的目标。不确定是否可能 bsoncxx::builder::basic::make_document;选项可能已被删除或替换为我不知道的其他内容。

在当前的主分支中,document.hpp 文件包含make_document方法。如果我没记错的话,您使用的是稳定的发布版本。

看看这里。在MongoDB c ++驱动程序中使用声明"未找到"