我试图通过 mongocxx 仅提取关键属性,但使用 find() 和 find_one() 函数。我无法仅提取关键值。
int main(int, char**)
{
mongocxx::instance inst{};
mongocxx::client conn{mongocxx::uri{}};
auto collection = conn["test"]["restaurants"];
bsoncxx::stdx::optional<bsoncxx::document::value> maybe_result =collection.find_one(document{} << finalize);
if(maybe_result)
{
std::cout <<bsoncxx::to_json(*maybe_result)<< "\n";
}
}
上面的代码仅提取带有键及其值的一个文档,而我只需要键。
谁可以帮我这个事?
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)