MongoDB 使用C++ driver 3.1.1 使用案例1
来源:互联网 发布:代运营淘宝如何收费用 编辑:程序博客网 时间:2024/04/30 02:45
#include <cstdint>#include <iostream>#include <vector>#include <bsoncxx/json.hpp>#include <mongocxx/client.hpp>#include <mongocxx/stdx.hpp>#include <mongocxx/uri.hpp>#include <mongocxx/instance.hpp>using bsoncxx::builder::stream::close_array;using bsoncxx::builder::stream::close_document;using bsoncxx::builder::stream::document;using bsoncxx::builder::stream::finalize;using bsoncxx::builder::stream::open_array;using bsoncxx::builder::stream::open_document;#pragma comment(lib, "bsoncxx.lib")#pragma comment(lib, "mongocxx.lib")#pragma comment(lib, "bson-1.0.lib")#pragma comment(lib, "mongoc-1.0.lib")int main(){mongocxx::instance instance = {};mongocxx::uri uri("mongodb://127.0.0.1:27017");mongocxx::client client(uri);mongocxx::database db = client["mydb"];db.create_collection("www");mongocxx::collection coll = db["test"];auto builder = bsoncxx::builder::stream::document{};bsoncxx::document::value doc_value = builder<< "name" << "MongoDB"<< "type" << "database"<< "count" << 1<< "versions" << bsoncxx::builder::stream::open_array<< "v3.2" << "v3.0" << "v2.6"<< close_array<< "info" << bsoncxx::builder::stream::open_document<< "x" << 203<< "y" << 102<< bsoncxx::builder::stream::close_document<< bsoncxx::builder::stream::finalize;bsoncxx::document::view view = doc_value.view();bsoncxx::document::element element = view["name"];if (element.type() != bsoncxx::type::k_utf8) {// Error}std::string name = element.get_utf8().value.to_string();}
0 0
- MongoDB 使用C++ driver 3.1.1 使用案例1
- mongodb c driver的使用总结(1)
- Mongodb c Driver 使用实例
- mongoDB C Driver使用介绍
- MongoDB Java Driver 使用
- MongoDB 2.4.1 C++ driver编译和使用
- mongodb安装和mongo-c-driver的安装使用
- 使用c++driver实现mongodb空间数据查询
- 使用MongoDB C Driver时遇到的问题解决汇总
- Mongodb matlab Driver 使用简介
- MongoDB C++ Driver 使用入门
- MongoDB基本的操作及C接口使用-MongoDB C Driver
- MongoDB笔记一,Win10上使用C Driver访问MongoDB Server
- mongodb c++ driver 2.0编译使用
- MongoDB java客户端mongo-java-driver使用
- mongodb-driver-async 如何使用GridFS
- MongoDB C# Driver 使用示例 (2.2)
- MongoDB C# Driver 使用示例 (2.2)
- 《R语言入门》如何在Windows下安装R语言编程环境
- 2-2 Time类的定义
- window.location.hash属性介绍
- mybatis学习小结(四)
- 四大组件 — ContentProvider
- MongoDB 使用C++ driver 3.1.1 使用案例1
- POJ 1753 (暴力搜索)
- 一台机器同时启动多个tomcat
- POJ 2376-Cleaning Shifts [贪心] [区间] 《挑战程序设计竞赛》2.2
- Struts2--6.@InputConfig
- kubernetes1.6.1安装
- 最小公倍数最大可以为多少(主要看计算方法)
- java代码实现链表
- 蓝桥杯Problem C: 啤酒和饮料