一个简单的MongoDB C ++程序在运行时什么也不做

时间:2017-06-12 17:42:55

标签: c++ mongodb

我有以下C ++ MongoDB;

#include <iostream>

#include <bsoncxx/builder/stream/document.hpp>
#include <bsoncxx/json.hpp>

#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>


int main(int, char**)
{
    std::cout << "\nStart" << std::endl;
    mongocxx::instance inst{};
    mongocxx::client conn{mongocxx::uri{}};

    bsoncxx::builder::stream::document document{};

    auto collection = conn["testdb"]["testcollection"];
    document << "hello" << "world";

    collection.insert_one(document.view());
    auto cursor = collection.find({});

    for (auto&& doc : cursor) {
        std::cout << bsoncxx::to_json(doc) << std::endl;
    }

    std::cout << "end" << std::endl;
}

编译运行良好且没有错误,但是从cmd运行时它根本不执行任何操作。我做错了什么?

0 个答案:

没有答案