c++ - 在 mongodb c++ 驱动程序中使用声明 "not found"

标签 c++ mongodb

我正在使用基于 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 相同的问题)。

这是包含、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_documentmake_array 所需的所有必要头文件。 你在评论中说,document.hpp不包含 make_documentarray.hpp不包含 make_array 模板。 这适用于版本 mongo-cxx-driver-r3.1.1

在当前的 master 分支中,头文件存在,如果您点击它们的源链接就可以看到:document.hpparray.hpp .您使用的示例可能适用于新的 master 分支,因为它们也来自 git 的当前分支。

关于c++ - 在 mongodb c++ 驱动程序中使用声明 "not found",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44540858/

相关文章:

spring - 蒙戈 : repositories no longer works

c++ - 如何暂停关闭按钮功能一段时间?

python - Mongoengine:以 EmbededDocuments 作为值的动态字段

node.js - 我无法通过名称连接到我的 mongo docker 容器

c++ - Eigen 矩阵似乎保留了不同范围内的内存

node.js - Monk可以直接返回json数据而不是promise吗?

javascript - 在 node.js 上使用 mongoose 过滤查询结果

c++ - FBO 在 OSX 中无法正常工作

c++ - 关于C++中没有默认构造函数的数组的一个问题

c++ - 查找相邻节点 A Star Path-Finding C++