我使用基於mongo-c-driver-1.6.2的mongo-cxx-driver-r3.1.1。 使用latest examples provided on github,我設法找到了如何連接數據庫以及如何保存文檔。在mongodb C++驅動程序中使用聲明「未找到」
我很努力地按照mongocxx/query.cpp example中提供的信息使用過濾器獲取結果。
對make_document方法有很多調用,但是我沒有使用該名稱的bsoncxx命名空間中的類/方法/模板(與make_array的問題相同)。
繼承人是在包括using指令和using聲明:
#include <bsoncxx/builder/basic/document.hpp>
#include <bsoncxx/builder/basic/array.hpp>
#include <bsoncxx/builder/basic/kvp.hpp>
#include <bsoncxx/types.hpp>
#include <bsoncxx/json.hpp>
#include <bsoncxx/stdx/make_unique.hpp>
#include <bsoncxx/stdx/optional.hpp>
#include <bsoncxx/stdx/string_view.hpp>
#include <mongocxx/instance.hpp>
#include <mongocxx/pool.hpp>
#include <mongocxx/stdx.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/logger.hpp>
#include <mongocxx/uri.hpp>
#include <mongocxx/exception/exception.hpp>
#include <mongocxx/options/find.hpp>
using namespace mongocxx;
using namespace bsoncxx;
using bsoncxx::builder::basic::document;
using bsoncxx::builder::basic::kvp;
using bsoncxx::builder::basic::sub_document;
using bsoncxx::builder::basic::sub_array;
using bsoncxx::builder::basic::array;
using bsoncxx::types::value;
using mongocxx::result::insert_one;
的使用聲明 「未找到」:
using bsoncxx::builder::basic::make_array;
using bsoncxx::builder::basic::make_document;
我失去了一些東西明顯? 有更近的例子嗎?
奇怪的是,'make_document'在[document.hpp]中(https://github.com/mongodb/mongo-cxx-driver/blob/master/src/bsoncxx/builder/basic/document.hpp)和'make_array'在[array.hpp]中(https://github.com/mongodb/mongo-cxx-driver/blob/master/src/bsoncxx/builder/basic/array.hpp),你都包括在內。你能否提供你的編譯器的實際錯誤信息? –
謝謝!你幫我注意到我的document.hpp沒有包含make_document模板(和array.hpp的make_array模板)。 我打算在今天下午添加它們並進行測試。有消息通知你。 – Francois