1

错误:二进制表达式的操作数无效('key_context >>' 和 'bsoncxx::v_noabi::builder::stream::document') 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);
4

0 回答 0