Mongodb C++ 驱动程序问题

Mongodb c++ driver issue

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

我使用的是mongo-cxx-driver-r3.1.1版本。 i have followed example from here

这是我试过的

       #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" } };

see image here

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

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

看看这里。