Extract key attributes mongocxx

核能气质少年 提交于 2019-12-11 07:25:00

问题


I am trying to extract only key attributes through mongocxx but using find() and find_one() function .I am not able to pull only key values.

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";
    }
} 

Above code pull only the one document with keys and their values and I want only keys. Can anyone help me on this?

来源:https://stackoverflow.com/questions/46680578/extract-key-attributes-mongocxx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!