0
데이터베이스에있는 모든 콜렉션의 목록을 가져 와서 사용하려고했습니다 : 커서 list_collections (bsoncxx :: document :: view filter = {});mongocxx를 사용하여 데이터베이스의 모든 컬렉션을 나열하십시오.
하지만 컬렉션을 반복 할 수 없습니다.
아무도 도와 줄 수 있습니까?
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;
}
}
: