【发布时间】:2017-06-14 09:34:23
【问题描述】:
我正在使用基于 mongo-c-driver-1.6.2 的 mongo-cxx-driver-r3.1.1。 使用latest examples provided on github,我设法找到了如何连接数据库以及如何保存文档。
我正在努力按照mongocxx/query.cpp example 中提供的信息使用过滤器获取结果。
对 make_document 方法有很多调用,但我在 bsoncxx 命名空间中没有具有该名称的类/方法/模板(与 make_array 相同的问题)。
这是包含、使用指令和使用声明:
#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 中,make_array在 array.hpp 中,你们都包括在内。您能否提供您的编译器的实际错误消息? -
谢谢!您帮助我注意到我的 document.hpp 不包含 make_document 模板(和 array.hpp make_array 模板)。我将添加它们并在今天下午进行测试。我会及时通知你的。