listCollections method
Analogue to shell's show collections
This method uses system collections and therefore do not work on MongoDB v3.0 with and upward
with WiredTiger
Use getCollectionNames
instead
Implementation
@Deprecated('Use `getCollectionNames` instead')
Future<List<String?>> listCollections() async {
if (masterConnection.serverCapabilities.supportsOpMsg) {
var ret = await modernListCollections().toList();
return [
for (var element in ret)
for (var nameKey in element.keys)
if (nameKey == keyName) element[keyName]
];
}
return _collectionsInfoCursor()
.map((map) => map['name']?.toString().split('.'))
.where((arr) => arr != null && arr.length == 2)
.map((arr) => arr?.last)
.toList();
}