0
データベースに存在するすべてのコレクションのリストをプルして使用しようとしています: cursor 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;
}
}
: