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?