@ThreadSafe public interface MongoDatabase
Note: Additions to this interface will not be considered to break binary compatibility.
| Modifier and Type | Method and Description | 
|---|---|
org.reactivestreams.Publisher<Success> | 
createCollection(ClientSession clientSession,
                String collectionName)
Create a new collection with the given name. 
 | 
org.reactivestreams.Publisher<Success> | 
createCollection(ClientSession clientSession,
                String collectionName,
                CreateCollectionOptions options)
Create a new collection with the selected options 
 | 
org.reactivestreams.Publisher<Success> | 
createCollection(String collectionName)
Create a new collection with the given name. 
 | 
org.reactivestreams.Publisher<Success> | 
createCollection(String collectionName,
                CreateCollectionOptions options)
Create a new collection with the selected options 
 | 
org.reactivestreams.Publisher<Success> | 
createView(ClientSession clientSession,
          String viewName,
          String viewOn,
          List<? extends Bson> pipeline)
Creates a view with the given name, backing collection/view name, and aggregation pipeline that defines the view. 
 | 
org.reactivestreams.Publisher<Success> | 
createView(ClientSession clientSession,
          String viewName,
          String viewOn,
          List<? extends Bson> pipeline,
          CreateViewOptions createViewOptions)
Creates a view with the given name, backing collection/view name, aggregation pipeline, and options that defines the view. 
 | 
org.reactivestreams.Publisher<Success> | 
createView(String viewName,
          String viewOn,
          List<? extends Bson> pipeline)
Creates a view with the given name, backing collection/view name, and aggregation pipeline that defines the view. 
 | 
org.reactivestreams.Publisher<Success> | 
createView(String viewName,
          String viewOn,
          List<? extends Bson> pipeline,
          CreateViewOptions createViewOptions)
Creates a view with the given name, backing collection/view name, aggregation pipeline, and options that defines the view. 
 | 
org.reactivestreams.Publisher<Success> | 
drop()
Drops this database. 
 | 
org.reactivestreams.Publisher<Success> | 
drop(ClientSession clientSession)
Drops this database. 
 | 
CodecRegistry | 
getCodecRegistry()
Get the codec registry for the MongoDatabase. 
 | 
MongoCollection<Document> | 
getCollection(String collectionName)
Gets a collection. 
 | 
<TDocument> | 
getCollection(String collectionName,
             Class<TDocument> clazz)
Gets a collection, with a specific default document class. 
 | 
String | 
getName()
Gets the name of the database. 
 | 
ReadConcern | 
getReadConcern()
Get the read concern for the MongoCollection. 
 | 
ReadPreference | 
getReadPreference()
Get the read preference for the MongoDatabase. 
 | 
WriteConcern | 
getWriteConcern()
Get the write concern for the MongoDatabase. 
 | 
org.reactivestreams.Publisher<String> | 
listCollectionNames()
Gets the names of all the collections in this database. 
 | 
org.reactivestreams.Publisher<String> | 
listCollectionNames(ClientSession clientSession)
Gets the names of all the collections in this database. 
 | 
ListCollectionsPublisher<Document> | 
listCollections()
Finds all the collections in this database. 
 | 
<TResult> ListCollectionsPublisher<TResult> | 
listCollections(Class<TResult> clazz)
Finds all the collections in this database. 
 | 
ListCollectionsPublisher<Document> | 
listCollections(ClientSession clientSession)
Finds all the collections in this database. 
 | 
<TResult> ListCollectionsPublisher<TResult> | 
listCollections(ClientSession clientSession,
               Class<TResult> clazz)
Finds all the collections in this database. 
 | 
org.reactivestreams.Publisher<Document> | 
runCommand(Bson command)
Executes command in the context of the current database. 
 | 
<TResult> org.reactivestreams.Publisher<TResult> | 
runCommand(Bson command,
          Class<TResult> clazz)
Executes command in the context of the current database. 
 | 
org.reactivestreams.Publisher<Document> | 
runCommand(Bson command,
          ReadPreference readPreference)
Executes command in the context of the current database. 
 | 
<TResult> org.reactivestreams.Publisher<TResult> | 
runCommand(Bson command,
          ReadPreference readPreference,
          Class<TResult> clazz)
Executes command in the context of the current database. 
 | 
org.reactivestreams.Publisher<Document> | 
runCommand(ClientSession clientSession,
          Bson command)
Executes command in the context of the current database. 
 | 
<TResult> org.reactivestreams.Publisher<TResult> | 
runCommand(ClientSession clientSession,
          Bson command,
          Class<TResult> clazz)
Executes command in the context of the current database. 
 | 
org.reactivestreams.Publisher<Document> | 
runCommand(ClientSession clientSession,
          Bson command,
          ReadPreference readPreference)
Executes command in the context of the current database. 
 | 
<TResult> org.reactivestreams.Publisher<TResult> | 
runCommand(ClientSession clientSession,
          Bson command,
          ReadPreference readPreference,
          Class<TResult> clazz)
Executes command in the context of the current database. 
 | 
ChangeStreamPublisher<Document> | 
watch()
Creates a change stream for this database. 
 | 
<TResult> ChangeStreamPublisher<TResult> | 
watch(Class<TResult> resultClass)
Creates a change stream for this database. 
 | 
ChangeStreamPublisher<Document> | 
watch(ClientSession clientSession)
Creates a change stream for this database. 
 | 
<TResult> ChangeStreamPublisher<TResult> | 
watch(ClientSession clientSession,
     Class<TResult> resultClass)
Creates a change stream for this database. 
 | 
ChangeStreamPublisher<Document> | 
watch(ClientSession clientSession,
     List<? extends Bson> pipeline)
Creates a change stream for this database. 
 | 
<TResult> ChangeStreamPublisher<TResult> | 
watch(ClientSession clientSession,
     List<? extends Bson> pipeline,
     Class<TResult> resultClass)
Creates a change stream for this database. 
 | 
ChangeStreamPublisher<Document> | 
watch(List<? extends Bson> pipeline)
Creates a change stream for this database. 
 | 
<TResult> ChangeStreamPublisher<TResult> | 
watch(List<? extends Bson> pipeline,
     Class<TResult> resultClass)
Creates a change stream for this database. 
 | 
MongoDatabase | 
withCodecRegistry(CodecRegistry codecRegistry)
Create a new MongoDatabase instance with a different codec registry. 
 | 
MongoDatabase | 
withReadConcern(ReadConcern readConcern)
Create a new MongoDatabase instance with a different read concern. 
 | 
MongoDatabase | 
withReadPreference(ReadPreference readPreference)
Create a new MongoDatabase instance with a different read preference. 
 | 
MongoDatabase | 
withWriteConcern(WriteConcern writeConcern)
Create a new MongoDatabase instance with a different write concern. 
 | 
String getName()
CodecRegistry getCodecRegistry()
CodecRegistryReadPreference getReadPreference()
ReadPreferenceWriteConcern getWriteConcern()
WriteConcernReadConcern getReadConcern()
ReadConcernMongoDatabase withCodecRegistry(CodecRegistry codecRegistry)
codecRegistry - the new CodecRegistry for the collectionMongoDatabase withReadPreference(ReadPreference readPreference)
readPreference - the new ReadPreference for the collectionMongoDatabase withWriteConcern(WriteConcern writeConcern)
writeConcern - the new WriteConcern for the collectionMongoDatabase withReadConcern(ReadConcern readConcern)
readConcern - the new ReadConcern for the collectionMongoCollection<Document> getCollection(String collectionName)
collectionName - the name of the collection to return<TDocument> MongoCollection<TDocument> getCollection(String collectionName, Class<TDocument> clazz)
TDocument - the type of the class to use instead of Document.collectionName - the name of the collection to returnclazz - the default class to cast any documents returned from the database into.org.reactivestreams.Publisher<Document> runCommand(Bson command)
command - the command to be runorg.reactivestreams.Publisher<Document> runCommand(Bson command, ReadPreference readPreference)
command - the command to be runreadPreference - the ReadPreference to be used when executing the command<TResult> org.reactivestreams.Publisher<TResult> runCommand(Bson command, Class<TResult> clazz)
TResult - the type of the class to use instead of Document.command - the command to be runclazz - the default class to cast any documents returned from the database into.<TResult> org.reactivestreams.Publisher<TResult> runCommand(Bson command, ReadPreference readPreference, Class<TResult> clazz)
TResult - the type of the class to use instead of Document.command - the command to be runreadPreference - the ReadPreference to be used when executing the commandclazz - the default class to cast any documents returned from the database into.org.reactivestreams.Publisher<Document> runCommand(ClientSession clientSession, Bson command)
clientSession - the client session with which to associate this operationcommand - the command to be runorg.reactivestreams.Publisher<Document> runCommand(ClientSession clientSession, Bson command, ReadPreference readPreference)
clientSession - the client session with which to associate this operationcommand - the command to be runreadPreference - the ReadPreference to be used when executing the command<TResult> org.reactivestreams.Publisher<TResult> runCommand(ClientSession clientSession, Bson command, Class<TResult> clazz)
TResult - the type of the class to use instead of Document.clientSession - the client session with which to associate this operationcommand - the command to be runclazz - the default class to cast any documents returned from the database into.<TResult> org.reactivestreams.Publisher<TResult> runCommand(ClientSession clientSession, Bson command, ReadPreference readPreference, Class<TResult> clazz)
TResult - the type of the class to use instead of Document.clientSession - the client session with which to associate this operationcommand - the command to be runreadPreference - the ReadPreference to be used when executing the commandclazz - the default class to cast any documents returned from the database into.org.reactivestreams.Publisher<Success> drop()
org.reactivestreams.Publisher<Success> drop(ClientSession clientSession)
clientSession - the client session with which to associate this operationorg.reactivestreams.Publisher<String> listCollectionNames()
org.reactivestreams.Publisher<String> listCollectionNames(ClientSession clientSession)
clientSession - the client session with which to associate this operationListCollectionsPublisher<Document> listCollections()
<TResult> ListCollectionsPublisher<TResult> listCollections(Class<TResult> clazz)
TResult - the target document type of the iterable.clazz - the class to decode each document intoListCollectionsPublisher<Document> listCollections(ClientSession clientSession)
clientSession - the client session with which to associate this operation<TResult> ListCollectionsPublisher<TResult> listCollections(ClientSession clientSession, Class<TResult> clazz)
TResult - the target document type of the iterable.clientSession - the client session with which to associate this operationclazz - the class to decode each document intoorg.reactivestreams.Publisher<Success> createCollection(String collectionName)
collectionName - the name for the new collection to createorg.reactivestreams.Publisher<Success> createCollection(String collectionName, CreateCollectionOptions options)
collectionName - the name for the new collection to createoptions - various options for creating the collectionorg.reactivestreams.Publisher<Success> createCollection(ClientSession clientSession, String collectionName)
clientSession - the client session with which to associate this operationcollectionName - the name for the new collection to createorg.reactivestreams.Publisher<Success> createCollection(ClientSession clientSession, String collectionName, CreateCollectionOptions options)
clientSession - the client session with which to associate this operationcollectionName - the name for the new collection to createoptions - various options for creating the collectionorg.reactivestreams.Publisher<Success> createView(String viewName, String viewOn, List<? extends Bson> pipeline)
viewName - the name of the view to createviewOn - the backing collection/view for the viewpipeline - the pipeline that defines the vieworg.reactivestreams.Publisher<Success> createView(String viewName, String viewOn, List<? extends Bson> pipeline, CreateViewOptions createViewOptions)
viewName - the name of the view to createviewOn - the backing collection/view for the viewpipeline - the pipeline that defines the viewcreateViewOptions - various options for creating the vieworg.reactivestreams.Publisher<Success> createView(ClientSession clientSession, String viewName, String viewOn, List<? extends Bson> pipeline)
clientSession - the client session with which to associate this operationviewName - the name of the view to createviewOn - the backing collection/view for the viewpipeline - the pipeline that defines the vieworg.reactivestreams.Publisher<Success> createView(ClientSession clientSession, String viewName, String viewOn, List<? extends Bson> pipeline, CreateViewOptions createViewOptions)
clientSession - the client session with which to associate this operationviewName - the name of the view to createviewOn - the backing collection/view for the viewpipeline - the pipeline that defines the viewcreateViewOptions - various options for creating the viewChangeStreamPublisher<Document> watch()
<TResult> ChangeStreamPublisher<TResult> watch(Class<TResult> resultClass)
TResult - the target document type of the iterable.resultClass - the class to decode each document intoChangeStreamPublisher<Document> watch(List<? extends Bson> pipeline)
pipeline - the aggregation pipeline to apply to the change stream.<TResult> ChangeStreamPublisher<TResult> watch(List<? extends Bson> pipeline, Class<TResult> resultClass)
TResult - the target document type of the iterable.pipeline - the aggregation pipeline to apply to the change streamresultClass - the class to decode each document intoChangeStreamPublisher<Document> watch(ClientSession clientSession)
clientSession - the client session with which to associate this operation<TResult> ChangeStreamPublisher<TResult> watch(ClientSession clientSession, Class<TResult> resultClass)
TResult - the target document type of the iterable.clientSession - the client session with which to associate this operationresultClass - the class to decode each document intoChangeStreamPublisher<Document> watch(ClientSession clientSession, List<? extends Bson> pipeline)
clientSession - the client session with which to associate this operationpipeline - the aggregation pipeline to apply to the change stream.<TResult> ChangeStreamPublisher<TResult> watch(ClientSession clientSession, List<? extends Bson> pipeline, Class<TResult> resultClass)
TResult - the target document type of the iterable.clientSession - the client session with which to associate this operationpipeline - the aggregation pipeline to apply to the change streamresultClass - the class to decode each document into