Skip to content

Commit 56cdb16

Browse files
committed
Added extra create helpers to MongoClients
1 parent d7a489d commit 56cdb16

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

driver-async/src/main/com/mongodb/async/client/MongoClients.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@
3535
* @since 3.0
3636
*/
3737
public final class MongoClients {
38+
39+
/**
40+
* Creates a new client with the default connection string "mongodb://localhost".
41+
*
42+
* @return the client
43+
*/
44+
public static MongoClient create() {
45+
return create(new ConnectionString("mongodb://localhost"));
46+
}
47+
3848
/**
3949
* Create a new client with the given client settings.
4050
*
@@ -45,6 +55,16 @@ public static MongoClient create(final MongoClientSettings settings) {
4555
return new MongoClientImpl(settings, createCluster(settings, getStreamFactory(settings)));
4656
}
4757

58+
/**
59+
* Create a new client with the given connection string.
60+
*
61+
* @param connectionString the connection
62+
* @return the client
63+
*/
64+
public static MongoClient create(final String connectionString) {
65+
return create(new ConnectionString(connectionString));
66+
}
67+
4868
/**
4969
* Create a new client with the given connection string.
5070
*

0 commit comments

Comments
 (0)