public class FongoAsync extends Object implements com.mongodb.operation.AsyncOperationExecutor
This class doesn't implement Mongo, but does provide the same basic interface
Usage:
FongoAsync fongo = new FongoAsync("test server");
// if you need an instance of com.mongodb.async.MongoClient
com.mongodb.async.MongoClient mongo = fongo.getMongoClient();
| Modifier and Type | Field and Description |
|---|---|
static com.mongodb.connection.ServerVersion |
DEFAULT_SERVER_VERSION |
| Constructor and Description |
|---|
FongoAsync(String name) |
FongoAsync(String name,
com.mongodb.connection.ServerVersion serverVersion) |
FongoAsync(String name,
com.mongodb.connection.ServerVersion serverVersion,
org.bson.codecs.configuration.CodecRegistry codecRegistry) |
| Modifier and Type | Method and Description |
|---|---|
void |
dropDatabase(String dbName)
Drop db and all data from memory
|
<T> void |
execute(com.mongodb.operation.AsyncReadOperation<T> operation,
com.mongodb.ReadPreference readPreference,
com.mongodb.session.ClientSession session,
com.mongodb.async.SingleResultCallback<T> callback) |
<T> void |
execute(com.mongodb.operation.AsyncReadOperation<T> operation,
com.mongodb.ReadPreference readPreference,
com.mongodb.async.SingleResultCallback<T> callback)
Execute the read operation with the given read preference.
|
<T> void |
execute(com.mongodb.operation.AsyncWriteOperation<T> operation,
com.mongodb.session.ClientSession session,
com.mongodb.async.SingleResultCallback<T> callback) |
<T> void |
execute(com.mongodb.operation.AsyncWriteOperation<T> operation,
com.mongodb.async.SingleResultCallback<T> callback)
Execute the write operation.
|
com.mongodb.async.client.FongoAsyncMongoDatabase |
getDatabase(String databaseName)
equivalent to getDatabase in driver
multiple calls to this method return the same MongoDatabase instance
|
List<String> |
getDatabaseNames()
Get database names that have been used
|
Fongo |
getFongo() |
com.mongodb.async.client.MongoClient |
getMongo()
A mocked out instance of com.mongodb.Mongo
All methods calls are intercepted and execute associated Fongo method
|
com.mongodb.ServerAddress |
getServerAddress()
This will always be localhost:27017
|
com.mongodb.connection.ServerVersion |
getServerVersion() |
String |
toString() |
public static final com.mongodb.connection.ServerVersion DEFAULT_SERVER_VERSION
public FongoAsync(String name)
name - Used only for a nice toString in case you have multiple instancespublic FongoAsync(String name, com.mongodb.connection.ServerVersion serverVersion)
name - Used only for a nice toString in case you have multiple instancesserverVersion - version of the server to use for fongo.public FongoAsync(String name, com.mongodb.connection.ServerVersion serverVersion, org.bson.codecs.configuration.CodecRegistry codecRegistry)
name - Used only for a nice toString in case you have multiple instancesserverVersion - version of the server to use for fongo.codecRegistry - the codec registry used by fongo.public com.mongodb.async.client.FongoAsyncMongoDatabase getDatabase(String databaseName)
databaseName - name of the db.public List<String> getDatabaseNames()
public void dropDatabase(String dbName)
dbName - name of the database.public com.mongodb.ServerAddress getServerAddress()
public com.mongodb.async.client.MongoClient getMongo()
public <T> void execute(com.mongodb.operation.AsyncReadOperation<T> operation,
com.mongodb.ReadPreference readPreference,
com.mongodb.async.SingleResultCallback<T> callback)
execute in interface com.mongodb.operation.AsyncOperationExecutoroperation - the read operation.readPreference - the read preference.callback - the callback to be called when the operation has been executedpublic <T> void execute(com.mongodb.operation.AsyncReadOperation<T> operation,
com.mongodb.ReadPreference readPreference,
com.mongodb.session.ClientSession session,
com.mongodb.async.SingleResultCallback<T> callback)
execute in interface com.mongodb.operation.AsyncOperationExecutorpublic <T> void execute(com.mongodb.operation.AsyncWriteOperation<T> operation,
com.mongodb.async.SingleResultCallback<T> callback)
execute in interface com.mongodb.operation.AsyncOperationExecutoroperation - the write operation.callback - the callback to be called when the operation has been executedpublic <T> void execute(com.mongodb.operation.AsyncWriteOperation<T> operation,
com.mongodb.session.ClientSession session,
com.mongodb.async.SingleResultCallback<T> callback)
execute in interface com.mongodb.operation.AsyncOperationExecutorpublic com.mongodb.connection.ServerVersion getServerVersion()
public Fongo getFongo()
Copyright © 2018. All rights reserved.