使用MongoDB C + 11驱动程序将多个嵌套查询组合失败

时间:2016-03-08 08:23:59

标签: mongodb mongo-c-driver mongo-cxx-driver

错误:二进制表达式的操作数无效       (' key_context>>'和       ' bsoncxx :: v_noabi ::助洗剂::流::文件')                 open_document<< conditionI<< close_document<<                 ~~~~~~~~~~~~~ ^ ~~~~~~~~~~

    using bsoncxx::builder::stream::document;
    using bsoncxx::builder::stream::open_document;
    using bsoncxx::builder::stream::close_document;
    using bsoncxx::builder::stream::open_array;
    using bsoncxx::builder::stream::close_array;
    using bsoncxx::builder::stream::finalize;

    typedef mongocxx::cursor::iterator dociter;
    typedef bsoncxx::v_noabi::document::view docview;

    mongocxx::instance inst{};
    mongocxx::client conn{mongocxx::uri{"mongodb://10.9.0.1:27017"}};
    mongocxx::collection collection = conn["crawler"]["article"];

    mongocxx::options::find opts;
    document query, conditionI, conditionII, options;
    conditionI << "publishTime" << open_document << "$gte" << timedomain << close_document;
    conditionII << "lastread" << open_document << "$gte" << readdomain << close_document;
    options << "read" << 1 << "likes" << 1 << "body.title" << 1 << "body.content" << 1;
    opts.limit(100);
    opts.sort(options.view());

    query << "$or" << open_array <<
            open_document << conditionI << close_document <<
            open_document << conditionII << close_document <<
            close_array;

    mongocxx::cursor cursor = collection.find(conditionI.view(), opts);

0 个答案:

没有答案