2017-10-16 5 views

Répondre

0

obtenu la réponse:

int main(int, char**) 
{ 
    mongocxx::instance inst{}; 
    mongocxx::client conn{mongocxx::uri{}}; 
    // auto collection = conn["test"]["restaurants"]; 
    mongocxx::database db = conn["test"]; 
    auto cursor1 = db.list_collections(); 
    for (const bsoncxx::document::view& doc :cursor1) 
    { 
     bsoncxx::document::element ele = doc["name"]; 
     std::string name = ele.get_utf8().value.to_string(); 
     std::cout <<name<< std::endl; 

    } 
}