Package com.mongodb.client
Interface MongoDatabase
- 
@ThreadSafe @Deprecated(since="2021-05-27") public interface MongoDatabase
Deprecated.Usage of this API is not supported in AEM as a Cloud Service.The MongoDatabase interface.Note: Additions to this interface will not be considered to break binary compatibility.
- Since:
 - 3.0
 
 
- 
- 
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description AggregateIterable<Document>aggregate(ClientSession clientSession, java.util.List<? extends Bson> pipeline)Deprecated.Runs an aggregation framework pipeline on the database for pipeline stages that do not require an underlying collection, such as$currentOpand$listLocalSessions.<TResult> AggregateIterable<TResult>aggregate(ClientSession clientSession, java.util.List<? extends Bson> pipeline, java.lang.Class<TResult> resultClass)Deprecated.Runs an aggregation framework pipeline on the database for pipeline stages that do not require an underlying collection, such as$currentOpand$listLocalSessions.AggregateIterable<Document>aggregate(java.util.List<? extends Bson> pipeline)Deprecated.Runs an aggregation framework pipeline on the database for pipeline stages that do not require an underlying collection, such as$currentOpand$listLocalSessions.<TResult> AggregateIterable<TResult>aggregate(java.util.List<? extends Bson> pipeline, java.lang.Class<TResult> resultClass)Deprecated.Runs an aggregation framework pipeline on the database for pipeline stages that do not require an underlying collection, such as$currentOpand$listLocalSessions.voidcreateCollection(ClientSession clientSession, java.lang.String collectionName)Deprecated.Create a new collection with the given name.voidcreateCollection(ClientSession clientSession, java.lang.String collectionName, CreateCollectionOptions createCollectionOptions)Deprecated.Create a new collection with the selected optionsvoidcreateCollection(java.lang.String collectionName)Deprecated.Create a new collection with the given name.voidcreateCollection(java.lang.String collectionName, CreateCollectionOptions createCollectionOptions)Deprecated.Create a new collection with the selected optionsvoidcreateView(ClientSession clientSession, java.lang.String viewName, java.lang.String viewOn, java.util.List<? extends Bson> pipeline)Deprecated.Creates a view with the given name, backing collection/view name, and aggregation pipeline that defines the view.voidcreateView(ClientSession clientSession, java.lang.String viewName, java.lang.String viewOn, java.util.List<? extends Bson> pipeline, CreateViewOptions createViewOptions)Deprecated.Creates a view with the given name, backing collection/view name, aggregation pipeline, and options that defines the view.voidcreateView(java.lang.String viewName, java.lang.String viewOn, java.util.List<? extends Bson> pipeline)Deprecated.Creates a view with the given name, backing collection/view name, and aggregation pipeline that defines the view.voidcreateView(java.lang.String viewName, java.lang.String viewOn, java.util.List<? extends Bson> pipeline, CreateViewOptions createViewOptions)Deprecated.Creates a view with the given name, backing collection/view name, aggregation pipeline, and options that defines the view.voiddrop()Deprecated.Drops this database.voiddrop(ClientSession clientSession)Deprecated.Drops this database.CodecRegistrygetCodecRegistry()Deprecated.Get the codec registry for the MongoDatabase.MongoCollection<Document>getCollection(java.lang.String collectionName)Deprecated.Gets a collection.<TDocument>
MongoCollection<TDocument>getCollection(java.lang.String collectionName, java.lang.Class<TDocument> documentClass)Deprecated.Gets a collection, with a specific default document class.java.lang.StringgetName()Deprecated.Gets the name of the database.ReadConcerngetReadConcern()Deprecated.Get the read concern for the MongoDatabase.ReadPreferencegetReadPreference()Deprecated.Get the read preference for the MongoDatabase.WriteConcerngetWriteConcern()Deprecated.Get the write concern for the MongoDatabase.MongoIterable<java.lang.String>listCollectionNames()Deprecated.Gets the names of all the collections in this database.MongoIterable<java.lang.String>listCollectionNames(ClientSession clientSession)Deprecated.Gets the names of all the collections in this database.ListCollectionsIterable<Document>listCollections()Deprecated.Finds all the collections in this database.ListCollectionsIterable<Document>listCollections(ClientSession clientSession)Deprecated.Finds all the collections in this database.<TResult> ListCollectionsIterable<TResult>listCollections(ClientSession clientSession, java.lang.Class<TResult> resultClass)Deprecated.Finds all the collections in this database.<TResult> ListCollectionsIterable<TResult>listCollections(java.lang.Class<TResult> resultClass)Deprecated.Finds all the collections in this database.DocumentrunCommand(ClientSession clientSession, Bson command)Deprecated.Executes the given command in the context of the current database with a read preference ofReadPreference.primary().DocumentrunCommand(ClientSession clientSession, Bson command, ReadPreference readPreference)Deprecated.Executes the given command in the context of the current database with the given read preference.<TResult> TResultrunCommand(ClientSession clientSession, Bson command, ReadPreference readPreference, java.lang.Class<TResult> resultClass)Deprecated.Executes the given command in the context of the current database with the given read preference.<TResult> TResultrunCommand(ClientSession clientSession, Bson command, java.lang.Class<TResult> resultClass)Deprecated.Executes the given command in the context of the current database with a read preference ofReadPreference.primary().DocumentrunCommand(Bson command)Deprecated.Executes the given command in the context of the current database with a read preference ofReadPreference.primary().DocumentrunCommand(Bson command, ReadPreference readPreference)Deprecated.Executes the given command in the context of the current database with the given read preference.<TResult> TResultrunCommand(Bson command, ReadPreference readPreference, java.lang.Class<TResult> resultClass)Deprecated.Executes the given command in the context of the current database with the given read preference.<TResult> TResultrunCommand(Bson command, java.lang.Class<TResult> resultClass)Deprecated.Executes the given command in the context of the current database with a read preference ofReadPreference.primary().ChangeStreamIterable<Document>watch()Deprecated.Creates a change stream for this database.ChangeStreamIterable<Document>watch(ClientSession clientSession)Deprecated.Creates a change stream for this database.<TResult> ChangeStreamIterable<TResult>watch(ClientSession clientSession, java.lang.Class<TResult> resultClass)Deprecated.Creates a change stream for this database.ChangeStreamIterable<Document>watch(ClientSession clientSession, java.util.List<? extends Bson> pipeline)Deprecated.Creates a change stream for this database.<TResult> ChangeStreamIterable<TResult>watch(ClientSession clientSession, java.util.List<? extends Bson> pipeline, java.lang.Class<TResult> resultClass)Deprecated.Creates a change stream for this database.<TResult> ChangeStreamIterable<TResult>watch(java.lang.Class<TResult> resultClass)Deprecated.Creates a change stream for this database.ChangeStreamIterable<Document>watch(java.util.List<? extends Bson> pipeline)Deprecated.Creates a change stream for this database.<TResult> ChangeStreamIterable<TResult>watch(java.util.List<? extends Bson> pipeline, java.lang.Class<TResult> resultClass)Deprecated.Creates a change stream for this database.MongoDatabasewithCodecRegistry(CodecRegistry codecRegistry)Deprecated.Create a new MongoDatabase instance with a different codec registry.MongoDatabasewithReadConcern(ReadConcern readConcern)Deprecated.Create a new MongoDatabase instance with a different read concern.MongoDatabasewithReadPreference(ReadPreference readPreference)Deprecated.Create a new MongoDatabase instance with a different read preference.MongoDatabasewithWriteConcern(WriteConcern writeConcern)Deprecated.Create a new MongoDatabase instance with a different write concern. 
 - 
 
- 
- 
Method Detail
- 
getName
java.lang.String getName()
Deprecated.Gets the name of the database.- Returns:
 - the database name
 
 
- 
getCodecRegistry
CodecRegistry getCodecRegistry()
Deprecated.Get the codec registry for the MongoDatabase.- Returns:
 - the 
CodecRegistry 
 
- 
getReadPreference
ReadPreference getReadPreference()
Deprecated.Get the read preference for the MongoDatabase.- Returns:
 - the 
ReadPreference 
 
- 
getWriteConcern
WriteConcern getWriteConcern()
Deprecated.Get the write concern for the MongoDatabase.- Returns:
 - the 
WriteConcern 
 
- 
getReadConcern
ReadConcern getReadConcern()
Deprecated.Get the read concern for the MongoDatabase.- Returns:
 - the 
ReadConcern - Since:
 - 3.2
 
 
- 
withCodecRegistry
MongoDatabase withCodecRegistry(CodecRegistry codecRegistry)
Deprecated.Create a new MongoDatabase instance with a different codec registry.- Parameters:
 codecRegistry- the newCodecRegistryfor the database- Returns:
 - a new MongoDatabase instance with the different codec registry
 
 
- 
withReadPreference
MongoDatabase withReadPreference(ReadPreference readPreference)
Deprecated.Create a new MongoDatabase instance with a different read preference.- Parameters:
 readPreference- the newReadPreferencefor the database- Returns:
 - a new MongoDatabase instance with the different readPreference
 
 
- 
withWriteConcern
MongoDatabase withWriteConcern(WriteConcern writeConcern)
Deprecated.Create a new MongoDatabase instance with a different write concern.- Parameters:
 writeConcern- the newWriteConcernfor the database- Returns:
 - a new MongoDatabase instance with the different writeConcern
 
 
- 
withReadConcern
MongoDatabase withReadConcern(ReadConcern readConcern)
Deprecated.Create a new MongoDatabase instance with a different read concern.- Parameters:
 readConcern- the newReadConcernfor the database- Returns:
 - a new MongoDatabase instance with the different ReadConcern
 - Since:
 - 3.2
 
 
- 
getCollection
MongoCollection<Document> getCollection(java.lang.String collectionName)
Deprecated.Gets a collection.- Parameters:
 collectionName- the name of the collection to return- Returns:
 - the collection
 - Throws:
 java.lang.IllegalArgumentException- if collectionName is invalid- See Also:
 MongoNamespace.checkCollectionNameValidity(String)
 
- 
getCollection
<TDocument> MongoCollection<TDocument> getCollection(java.lang.String collectionName, java.lang.Class<TDocument> documentClass)
Deprecated.Gets a collection, with a specific default document class.- Type Parameters:
 TDocument- the type of the class to use instead ofDocument.- Parameters:
 collectionName- the name of the collection to returndocumentClass- the default class to cast any documents returned from the database into.- Returns:
 - the collection
 
 
- 
runCommand
Document runCommand(Bson command)
Deprecated.Executes the given command in the context of the current database with a read preference ofReadPreference.primary().- Parameters:
 command- the command to be run- Returns:
 - the command result
 
 
- 
runCommand
Document runCommand(Bson command, ReadPreference readPreference)
Deprecated.Executes the given command in the context of the current database with the given read preference.- Parameters:
 command- the command to be runreadPreference- theReadPreferenceto be used when executing the command- Returns:
 - the command result
 
 
- 
runCommand
<TResult> TResult runCommand(Bson command, java.lang.Class<TResult> resultClass)
Deprecated.Executes the given command in the context of the current database with a read preference ofReadPreference.primary().- Type Parameters:
 TResult- the type of the class to use instead ofDocument.- Parameters:
 command- the command to be runresultClass- the class to decode each document into- Returns:
 - the command result
 
 
- 
runCommand
<TResult> TResult runCommand(Bson command, ReadPreference readPreference, java.lang.Class<TResult> resultClass)
Deprecated.Executes the given command in the context of the current database with the given read preference.- Type Parameters:
 TResult- the type of the class to use instead ofDocument.- Parameters:
 command- the command to be runreadPreference- theReadPreferenceto be used when executing the commandresultClass- the class to decode each document into- Returns:
 - the command result
 
 
- 
runCommand
Document runCommand(ClientSession clientSession, Bson command)
Deprecated.Executes the given command in the context of the current database with a read preference ofReadPreference.primary().- Parameters:
 clientSession- the client session with which to associate this operationcommand- the command to be run- Returns:
 - the command result
 - Since:
 - 3.6
 
 
- 
runCommand
Document runCommand(ClientSession clientSession, Bson command, ReadPreference readPreference)
Deprecated.Executes the given command in the context of the current database with the given read preference.- Parameters:
 clientSession- the client session with which to associate this operationcommand- the command to be runreadPreference- theReadPreferenceto be used when executing the command- Returns:
 - the command result
 - Since:
 - 3.6
 
 
- 
runCommand
<TResult> TResult runCommand(ClientSession clientSession, Bson command, java.lang.Class<TResult> resultClass)
Deprecated.Executes the given command in the context of the current database with a read preference ofReadPreference.primary().- Type Parameters:
 TResult- the type of the class to use instead ofDocument.- Parameters:
 clientSession- the client session with which to associate this operationcommand- the command to be runresultClass- the class to decode each document into- Returns:
 - the command result
 - Since:
 - 3.6
 
 
- 
runCommand
<TResult> TResult runCommand(ClientSession clientSession, Bson command, ReadPreference readPreference, java.lang.Class<TResult> resultClass)
Deprecated.Executes the given command in the context of the current database with the given read preference.- Type Parameters:
 TResult- the type of the class to use instead ofDocument.- Parameters:
 clientSession- the client session with which to associate this operationcommand- the command to be runreadPreference- theReadPreferenceto be used when executing the commandresultClass- the class to decode each document into- Returns:
 - the command result
 - Since:
 - 3.6
 
 
- 
drop
void drop()
Deprecated.Drops this database. 
- 
drop
void drop(ClientSession clientSession)
Deprecated.Drops this database.- Parameters:
 clientSession- the client session with which to associate this operation- Since:
 - 3.6
 
 
- 
listCollectionNames
MongoIterable<java.lang.String> listCollectionNames()
Deprecated.Gets the names of all the collections in this database.- Returns:
 - an iterable containing all the names of all the collections in this database
 
 
- 
listCollections
ListCollectionsIterable<Document> listCollections()
Deprecated.Finds all the collections in this database.- Returns:
 - the list collections iterable interface
 
 
- 
listCollections
<TResult> ListCollectionsIterable<TResult> listCollections(java.lang.Class<TResult> resultClass)
Deprecated.Finds all the collections in this database.- Type Parameters:
 TResult- the target document type of the iterable.- Parameters:
 resultClass- the class to decode each document into- Returns:
 - the list collections iterable interface
 
 
- 
listCollectionNames
MongoIterable<java.lang.String> listCollectionNames(ClientSession clientSession)
Deprecated.Gets the names of all the collections in this database.- Parameters:
 clientSession- the client session with which to associate this operation- Returns:
 - an iterable containing all the names of all the collections in this database
 - Since:
 - 3.6
 
 
- 
listCollections
ListCollectionsIterable<Document> listCollections(ClientSession clientSession)
Deprecated.Finds all the collections in this database.- Parameters:
 clientSession- the client session with which to associate this operation- Returns:
 - the list collections iterable interface
 - Since:
 - 3.6
 
 
- 
listCollections
<TResult> ListCollectionsIterable<TResult> listCollections(ClientSession clientSession, java.lang.Class<TResult> resultClass)
Deprecated.Finds all the collections in this database.- Type Parameters:
 TResult- the target document type of the iterable.- Parameters:
 clientSession- the client session with which to associate this operationresultClass- the class to decode each document into- Returns:
 - the list collections iterable interface
 - Since:
 - 3.6
 
 
- 
createCollection
void createCollection(java.lang.String collectionName)
Deprecated.Create a new collection with the given name.- Parameters:
 collectionName- the name for the new collection to create
 
- 
createCollection
void createCollection(java.lang.String collectionName, CreateCollectionOptions createCollectionOptions)Deprecated.Create a new collection with the selected options- Parameters:
 collectionName- the name for the new collection to createcreateCollectionOptions- various options for creating the collection
 
- 
createCollection
void createCollection(ClientSession clientSession, java.lang.String collectionName)
Deprecated.Create a new collection with the given name.- Parameters:
 clientSession- the client session with which to associate this operationcollectionName- the name for the new collection to create- Since:
 - 3.6
 
 
- 
createCollection
void createCollection(ClientSession clientSession, java.lang.String collectionName, CreateCollectionOptions createCollectionOptions)
Deprecated.Create a new collection with the selected options- Parameters:
 clientSession- the client session with which to associate this operationcollectionName- the name for the new collection to createcreateCollectionOptions- various options for creating the collection- Since:
 - 3.6
 
 
- 
createView
void createView(java.lang.String viewName, java.lang.String viewOn, java.util.List<? extends Bson> pipeline)Deprecated.Creates a view with the given name, backing collection/view name, and aggregation pipeline that defines the view.- Parameters:
 viewName- the name of the view to createviewOn- the backing collection/view for the viewpipeline- the pipeline that defines the view- Since:
 - 3.4
 
 
- 
createView
void createView(java.lang.String viewName, java.lang.String viewOn, java.util.List<? extends Bson> pipeline, CreateViewOptions createViewOptions)Deprecated.Creates a view with the given name, backing collection/view name, aggregation pipeline, and options that defines the view.- Parameters:
 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 view- Since:
 - 3.4
 
 
- 
createView
void createView(ClientSession clientSession, java.lang.String viewName, java.lang.String viewOn, java.util.List<? extends Bson> pipeline)
Deprecated.Creates a view with the given name, backing collection/view name, and aggregation pipeline that defines the view.- Parameters:
 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 view- Since:
 - 3.6
 
 
- 
createView
void createView(ClientSession clientSession, java.lang.String viewName, java.lang.String viewOn, java.util.List<? extends Bson> pipeline, CreateViewOptions createViewOptions)
Deprecated.Creates a view with the given name, backing collection/view name, aggregation pipeline, and options that defines the view.- Parameters:
 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 view- Since:
 - 3.6
 
 
- 
watch
ChangeStreamIterable<Document> watch()
Deprecated.Creates a change stream for this database.- Returns:
 - the change stream iterable
 - Since:
 - 3.8
 
 
- 
watch
<TResult> ChangeStreamIterable<TResult> watch(java.lang.Class<TResult> resultClass)
Deprecated.Creates a change stream for this database.- Type Parameters:
 TResult- the target document type of the iterable.- Parameters:
 resultClass- the class to decode each document into- Returns:
 - the change stream iterable
 - Since:
 - 3.8
 
 
- 
watch
ChangeStreamIterable<Document> watch(java.util.List<? extends Bson> pipeline)
Deprecated.Creates a change stream for this database.- Parameters:
 pipeline- the aggregation pipeline to apply to the change stream.- Returns:
 - the change stream iterable
 - Since:
 - 3.8
 
 
- 
watch
<TResult> ChangeStreamIterable<TResult> watch(java.util.List<? extends Bson> pipeline, java.lang.Class<TResult> resultClass)
Deprecated.Creates a change stream for this database.- Type Parameters:
 TResult- the target document type of the iterable.- Parameters:
 pipeline- the aggregation pipeline to apply to the change streamresultClass- the class to decode each document into- Returns:
 - the change stream iterable
 - Since:
 - 3.8
 
 
- 
watch
ChangeStreamIterable<Document> watch(ClientSession clientSession)
Deprecated.Creates a change stream for this database.- Parameters:
 clientSession- the client session with which to associate this operation- Returns:
 - the change stream iterable
 - Since:
 - 3.8
 
 
- 
watch
<TResult> ChangeStreamIterable<TResult> watch(ClientSession clientSession, java.lang.Class<TResult> resultClass)
Deprecated.Creates a change stream for this database.- Type Parameters:
 TResult- the target document type of the iterable.- Parameters:
 clientSession- the client session with which to associate this operationresultClass- the class to decode each document into- Returns:
 - the change stream iterable
 - Since:
 - 3.8
 
 
- 
watch
ChangeStreamIterable<Document> watch(ClientSession clientSession, java.util.List<? extends Bson> pipeline)
Deprecated.Creates a change stream for this database.- Parameters:
 clientSession- the client session with which to associate this operationpipeline- the aggregation pipeline to apply to the change stream.- Returns:
 - the change stream iterable
 - Since:
 - 3.8
 
 
- 
watch
<TResult> ChangeStreamIterable<TResult> watch(ClientSession clientSession, java.util.List<? extends Bson> pipeline, java.lang.Class<TResult> resultClass)
Deprecated.Creates a change stream for this database.- Type Parameters:
 TResult- the target document type of the iterable.- Parameters:
 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- Returns:
 - the change stream iterable
 - Since:
 - 3.8
 
 
- 
aggregate
AggregateIterable<Document> aggregate(java.util.List<? extends Bson> pipeline)
Deprecated.Runs an aggregation framework pipeline on the database for pipeline stages that do not require an underlying collection, such as$currentOpand$listLocalSessions.- Parameters:
 pipeline- the aggregation pipeline- Returns:
 - an iterable containing the result of the aggregation operation
 - Since:
 - 3.10
 
 
- 
aggregate
<TResult> AggregateIterable<TResult> aggregate(java.util.List<? extends Bson> pipeline, java.lang.Class<TResult> resultClass)
Deprecated.Runs an aggregation framework pipeline on the database for pipeline stages that do not require an underlying collection, such as$currentOpand$listLocalSessions.- Type Parameters:
 TResult- the target document type of the iterable.- Parameters:
 pipeline- the aggregation pipelineresultClass- the class to decode each document into- Returns:
 - an iterable containing the result of the aggregation operation
 - Since:
 - 3.10
 
 
- 
aggregate
AggregateIterable<Document> aggregate(ClientSession clientSession, java.util.List<? extends Bson> pipeline)
Deprecated.Runs an aggregation framework pipeline on the database for pipeline stages that do not require an underlying collection, such as$currentOpand$listLocalSessions.- Parameters:
 clientSession- the client session with which to associate this operationpipeline- the aggregation pipeline- Returns:
 - an iterable containing the result of the aggregation operation
 - Since:
 - 3.10
 
 
- 
aggregate
<TResult> AggregateIterable<TResult> aggregate(ClientSession clientSession, java.util.List<? extends Bson> pipeline, java.lang.Class<TResult> resultClass)
Deprecated.Runs an aggregation framework pipeline on the database for pipeline stages that do not require an underlying collection, such as$currentOpand$listLocalSessions.- Type Parameters:
 TResult- the target document type of the iterable.- Parameters:
 clientSession- the client session with which to associate this operationpipeline- the aggregation pipelineresultClass- the class to decode each document into- Returns:
 - an iterable containing the result of the aggregation operation
 - Since:
 - 3.10
 
 
 - 
 
 -