Created
November 16, 2018 22:11
-
-
Save rcarloslima/6b95e4d469ae22f5ae327b12b14dc396 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <bsoncxx/builder/stream/document.hpp> | |
#include <bsoncxx/json.hpp> | |
#include <mongocxx/client.hpp> | |
#include <mongocxx/instance.hpp> | |
int main(int, char**) { | |
mongocxx::instance inst{}; | |
mongocxx::client conn{mongocxx::uri{}}; | |
bsoncxx::builder::stream::document document{}; | |
auto collection = conn["testedb"]["testecollection"]; | |
document << "Mensagem" << "hello world"; | |
collection.insert_one(document.view()); | |
auto cursor = collection.find({}); | |
for (auto&& doc : cursor) { | |
std::cout << bsoncxx::to_json(doc) << std::endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment