parent
01418e44ad
commit
624befaec2
|
@ -47,9 +47,11 @@ class DatabaseViewController: NSViewController {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
mongoController.client.listDatabaseNames().flatMap { (databaseNames) -> EventLoopFuture<[DatabaseCollections]> in
|
mongoController.client.listDatabaseNames().flatMap { (databaseNames) -> EventLoopFuture<[DatabaseCollections]> in
|
||||||
let futures = databaseNames.map { (name) in
|
let futures = databaseNames.map { (name: String) -> EventLoopFuture<DatabaseCollections> in
|
||||||
self.mongoController.client.db(name).listCollectionNames().map { (collectionNames) in
|
let db = self.mongoController.client.db(name)
|
||||||
DatabaseCollections(database: name, collections: collectionNames)
|
return db.listCollectionNames().map { (collectionNames: [String]) -> DatabaseCollections in
|
||||||
|
let sortedNames = collectionNames.sorted()
|
||||||
|
return DatabaseCollections(database: name, collections: sortedNames)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return EventLoopFuture.whenAllSucceed(futures, on: futures.first!.eventLoop)
|
return EventLoopFuture.whenAllSucceed(futures, on: futures.first!.eventLoop)
|
||||||
|
@ -58,7 +60,8 @@ class DatabaseViewController: NSViewController {
|
||||||
|
|
||||||
switch res {
|
switch res {
|
||||||
case let .success(databaseCollections):
|
case let .success(databaseCollections):
|
||||||
self.databaseCollections = databaseCollections
|
let sortedCollections = databaseCollections.sorted(by: { $0.database < $1.database })
|
||||||
|
self.databaseCollections = sortedCollections
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.collectionsOutlineView.reloadData()
|
self.collectionsOutlineView.reloadData()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue