diff --git a/objc/NuMongoDB.h b/objc/NuMongoDB.h index 6e33ebc..34cb355 100644 --- a/objc/NuMongoDB.h +++ b/objc/NuMongoDB.h @@ -89,6 +89,8 @@ limitations under the License. - (id) runCommand:(id) command inDatabase:(NSString *) database; /*! Get the names of the collections in a database. */ - (id) collectionNamesInDatabase:(NSString *) database; +/*! Convenience method to list all the databases on the connected server. */ +- (id) listDatabases; /*! Remove a database. */ - (BOOL) dropDatabase:(NSString *) database; /*! Remove a collection. */ diff --git a/objc/NuMongoDB.m b/objc/NuMongoDB.m index 8e23f13..a116509 100644 --- a/objc/NuMongoDB.m +++ b/objc/NuMongoDB.m @@ -244,6 +244,11 @@ - (id) collectionNamesInDatabase:(NSString *) database return result; } +- (id) listDatabases +{ + return [self runCommand:[NSDictionary dictionaryWithObject:@"1" forKey:@"listDatabases"] inDatabase:@"admin"]; +} + - (BOOL) ensureCollection:(NSString *) collection hasIndex:(NSObject *) key withOptions:(int) options { bson output;