REACT-CPP-MONGO C++ 编写的异步 mongo 访问库开源项目

我要开发同款
匿名用户2018年03月05日
80阅读

技术信息

开源地址
https://github.com/CopernicaMarketingSoftware/REACT-CPP-MONGO
授权协议
Apache-2.0

作品详情

一个基于REACT-CPP的库,使用C++编写的异步mogo访问库。通过使用lambda表达式和回调函数的形式来返回查询结果。

这个库的工作原理与普通的mogoC++库基本相同,只是所有函数接受一个lambda参数,当结果可用(或失败)时将调用该参数。

示例代码

React::Mogo::Coectio mogo("mogodb.example.org", [](React::Mogo::Coectio *coectio, cost char *error) {    // if o error occured, we will receive a ull poiter    if (!error) std::cout << "Coected successfully" << std::edl;    // otherwise, we will get a descriptio of what exactly wet wrog    else std::cout << "Coectio error: " << error << std::edl;});/** *  The mogo object will be created immediately, eve though the coectio *  might ot have bee established. It is safe, however, to immediately ru *  the ext commad o the object. They will be executed after a coectio *  was established. Should the library fail to coect, all registered calls *  will receive a error. */// build a query to fid a specific documetVariat::Value query;query["_id"] = "documetid";// retrieve the documetmogo.query("database.collectio", std::move(query)).oSuccess([](Variat::Value&& result) {    // sice we search for a exact id, we will get a maximum of oe result    // however, this result will always be a array    if (result.size() == 0)    {        std::cout << "Could ot fid ay documet with that ID" << std::edl;        retur;    }    // assume that the documet has a strig field amed 'firstame'    std::strig firstame = result[0]["firstame"];}).oError([](cost char *error) {    std::cout << "Somethig wet wrog queryig: " << error << std::edl;});

功能介绍

一个基于 REACT-CPP 的库,使用 C++ 编写的异步 mongo 访问库。通过使用 lambda 表达式和回调函数的形式来返回查询结果。 这个库的工作原理与普通的 mongo C++ 库...

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论