使用声明“未找到";在mongodb c ++驱动程序中 [英] Using declaration "not found" in mongodb c++ driver

查看:137
本文介绍了使用声明“未找到";在mongodb c ++驱动程序中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用基于mongo-c-driver-1.6.2的mongo-cxx-driver-r3.1.1. 使用 github上提供的最新示例,我设法找到了如何连接数据库以及如何保存文档.

I'm using the mongo-cxx-driver-r3.1.1 based on mongo-c-driver-1.6.2. Using the latest examples provided on github, I managed to find how to connect the database and how to save documents.

我正在努力按照有很多对make_document方法的调用,但在bsoncxx名称空间中没有具有该名称的类/方法/模板(与make_array相同的问题).

There's a lot of call to a make_document method but I have no class/method/template in the bsoncxx namespace with that name (same problem with make_array).

以下是includes,using指令和using声明:

Heres's the includes, the using directives and using declarations :

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

我缺少明显的东西吗? 还有最近的例子吗?

Am I missing something obvious ? Are there more recent examples ?

推荐答案

您的代码看起来正确,因为其中包含了make_documentmake_array所需的所有必要的头文件. 您在评论中说,

Your code looks right, as you included all necessary header files needed for make_document and make_array. You said in your comment, that the document.hpp doesn't contain the make_document and the array.hpp doesn't contain the make_array template. This is right for the release mongo-cxx-driver-r3.1.1.

在当前的master分支中,头文件存在,您可以查看是否遵循它们的源链接:

In the current master branch the header files exists as you can see if you follow the source links for them: document.hpp and array.hpp. The examples you use are probably for the new master branch as they are also from a current branch from git.

这篇关于使用声明“未找到";在mongodb c ++驱动程序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆