2016-04-05 15 views
3
bsoncxx::builder::stream::document search_builder; 

mongocxx::options::find img_find; // This speeds up the queries 

search_builder_images.clear(); 
search_builder_images << "_id" << "abc" << "data" << open_document <<"$exists" << true << close_document ; 
for (bsoncxx::document::view doc : cursor_cal) { 
    std::cout << bsoncxx::to_json(doc) << std::endl; 
} 

auto cursor_cal = dbMongo [collectionName] .find(search_builder.view());

ここでランダムに50-50%のチャンスがありますが、時々私が期待している出力が得られますが、時々セグメンテーションフォールトエラーが発生します。

私は間違っていますか? (私はこのsearch_builderを作成してmongodbデータベースを検索し、データが存在する文書を取得しようとしています)

答えて

0

これは少し古くなっていますが、文書の作成にはsegfaultの問題がありました。直面していた。クエリ文書の構成を次のような複数の行に分割する必要がありました。

auto queryDoc = document{}; 
queryDoc << _id << "abc"; 
queryDoc << "data" << open_document; 
    queryDoc << "$exists" << true; 
queryDoc << close_document; 
auto query = queryDoc << finalize; 

これは他の人に役立つことを望みます。

関連する問題