问题描述
我想根据“ size”元素查询包含文档的数组。
{
"number": 0,"features": [{
"size": 10,"angle": 0.13546741008758545,"response": 0,},{
"size": 40,"angle": 0.3170666992664337,}]
}
我做了如下
//Create the query filter
auto filter = bsoncxx::builder::stream::document{} << "features.size"<< bsoncxx::builder::stream::open_document
<<"$gt" << 0
<<"$lte" << 30
<< bsoncxx::builder::stream::close_document << bsoncxx::builder::stream::finalize;
mongocxx::options::find opts;
opts.projection(bsoncxx::builder::basic::make_document(bsoncxx::builder::basic::kvp("features",1)));
auto cursor = db["deneme"].find(filter.view(),opts);
for (auto&& doc : cursor) {
std::cout << bsoncxx::to_json(doc) << std::endl;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)