class MongoDatabaseImpl extends java.lang.Object implements MongoDatabase
Modifier and Type | Field and Description |
---|---|
private CodecRegistry |
codecRegistry |
private AsyncOperationExecutor |
executor |
private java.lang.String |
name |
private ReadConcern |
readConcern |
private ReadPreference |
readPreference |
private boolean |
retryWrites |
private WriteConcern |
writeConcern |
Constructor and Description |
---|
MongoDatabaseImpl(java.lang.String name,
CodecRegistry codecRegistry,
ReadPreference readPreference,
WriteConcern writeConcern,
boolean retryWrites,
ReadConcern readConcern,
AsyncOperationExecutor executor) |
Modifier and Type | Method and Description |
---|---|
private java.util.List<BsonDocument> |
createBsonDocumentList(java.util.List<? extends Bson> pipeline) |
void |
createCollection(ClientSession clientSession,
java.lang.String collectionName,
CreateCollectionOptions options,
SingleResultCallback<java.lang.Void> callback)
Create a new collection with the selected options
|
void |
createCollection(ClientSession clientSession,
java.lang.String collectionName,
SingleResultCallback<java.lang.Void> callback)
Create a new collection with the given name.
|
void |
createCollection(java.lang.String collectionName,
CreateCollectionOptions createCollectionOptions,
SingleResultCallback<java.lang.Void> callback)
Create a new collection with the selected options
|
void |
createCollection(java.lang.String collectionName,
SingleResultCallback<java.lang.Void> callback)
Create a new collection with the given name.
|
private MongoIterable<java.lang.String> |
createListCollectionNamesIterable(ClientSession clientSession) |
private <TResult> ListCollectionsIterable<TResult> |
createListCollectionsIterable(ClientSession clientSession,
java.lang.Class<TResult> resultClass) |
void |
createView(ClientSession clientSession,
java.lang.String viewName,
java.lang.String viewOn,
java.util.List<? extends Bson> pipeline,
CreateViewOptions createViewOptions,
SingleResultCallback<java.lang.Void> callback)
Creates a view with the given name, backing collection/view name, aggregation pipeline, and options that defines the view.
|
void |
createView(ClientSession clientSession,
java.lang.String viewName,
java.lang.String viewOn,
java.util.List<? extends Bson> pipeline,
SingleResultCallback<java.lang.Void> callback)
Creates a view with the given name, backing collection/view name, and aggregation pipeline that defines the view.
|
void |
createView(java.lang.String viewName,
java.lang.String viewOn,
java.util.List<? extends Bson> pipeline,
CreateViewOptions createViewOptions,
SingleResultCallback<java.lang.Void> callback)
Creates a view with the given name, backing collection/view name, aggregation pipeline, and options that defines the view.
|
void |
createView(java.lang.String viewName,
java.lang.String viewOn,
java.util.List<? extends Bson> pipeline,
SingleResultCallback<java.lang.Void> callback)
Creates a view with the given name, backing collection/view name, and aggregation pipeline that defines the view.
|
void |
drop(ClientSession clientSession,
SingleResultCallback<java.lang.Void> callback)
Drops this database.
|
void |
drop(SingleResultCallback<java.lang.Void> callback)
Drops this database.
|
private <TResult> void |
executeCommand(ClientSession clientSession,
Bson command,
ReadPreference readPreference,
java.lang.Class<TResult> resultClass,
SingleResultCallback<TResult> callback) |
private void |
executeCreateCollection(ClientSession clientSession,
java.lang.String collectionName,
CreateCollectionOptions options,
SingleResultCallback<java.lang.Void> callback) |
private void |
executeCreateView(ClientSession clientSession,
java.lang.String viewName,
java.lang.String viewOn,
java.util.List<? extends Bson> pipeline,
CreateViewOptions createViewOptions,
SingleResultCallback<java.lang.Void> callback) |
private void |
executeDrop(ClientSession clientSession,
SingleResultCallback<java.lang.Void> callback) |
CodecRegistry |
getCodecRegistry()
Get the codec registry for the MongoDatabase.
|
MongoCollection<Document> |
getCollection(java.lang.String collectionName)
Gets a collection.
|
<TDocument> |
getCollection(java.lang.String collectionName,
java.lang.Class<TDocument> documentClass)
Gets a collection, with a specific default document class.
|
java.lang.String |
getName()
Gets the name of the database.
|
ReadConcern |
getReadConcern()
Get the read concern for the MongoDatabase.
|
ReadPreference |
getReadPreference()
Get the read preference for the MongoDatabase.
|
WriteConcern |
getWriteConcern()
Get the write concern for the MongoDatabase.
|
MongoIterable<java.lang.String> |
listCollectionNames()
Gets the names of all the collections in this database.
|
MongoIterable<java.lang.String> |
listCollectionNames(ClientSession clientSession)
Gets the names of all the collections in this database.
|
ListCollectionsIterable<Document> |
listCollections()
Finds all the collections in this database.
|
<TResult> ListCollectionsIterable<TResult> |
listCollections(java.lang.Class<TResult> resultClass)
Finds all the collections in this database.
|
ListCollectionsIterable<Document> |
listCollections(ClientSession clientSession)
Finds all the collections in this database.
|
<TResult> ListCollectionsIterable<TResult> |
listCollections(ClientSession clientSession,
java.lang.Class<TResult> resultClass)
Finds all the collections in this database.
|
<TResult> void |
runCommand(Bson command,
java.lang.Class<TResult> resultClass,
SingleResultCallback<TResult> callback)
Executes the given command in the context of the current database with a read preference of
ReadPreference.primary() . |
<TResult> void |
runCommand(Bson command,
ReadPreference readPreference,
java.lang.Class<TResult> resultClass,
SingleResultCallback<TResult> callback)
Executes the given command in the context of the current database with the given read preference.
|
void |
runCommand(Bson command,
ReadPreference readPreference,
SingleResultCallback<Document> callback)
Executes the given command in the context of the current database with the given read preference.
|
void |
runCommand(Bson command,
SingleResultCallback<Document> callback)
Executes the given command in the context of the current database with a read preference of
ReadPreference.primary() . |
<TResult> void |
runCommand(ClientSession clientSession,
Bson command,
java.lang.Class<TResult> resultClass,
SingleResultCallback<TResult> callback)
Executes the given command in the context of the current database with a read preference of
ReadPreference.primary() . |
<TResult> void |
runCommand(ClientSession clientSession,
Bson command,
ReadPreference readPreference,
java.lang.Class<TResult> resultClass,
SingleResultCallback<TResult> callback)
Executes the given command in the context of the current database with the given read preference.
|
void |
runCommand(ClientSession clientSession,
Bson command,
ReadPreference readPreference,
SingleResultCallback<Document> callback)
Executes the given command in the context of the current database with the given read preference.
|
void |
runCommand(ClientSession clientSession,
Bson command,
SingleResultCallback<Document> callback)
Executes the given command in the context of the current database with a read preference of
ReadPreference.primary() . |
private BsonDocument |
toBsonDocument(Bson document) |
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.
|
private final java.lang.String name
private final ReadPreference readPreference
private final CodecRegistry codecRegistry
private final WriteConcern writeConcern
private final boolean retryWrites
private final ReadConcern readConcern
private final AsyncOperationExecutor executor
MongoDatabaseImpl(java.lang.String name, CodecRegistry codecRegistry, ReadPreference readPreference, WriteConcern writeConcern, boolean retryWrites, ReadConcern readConcern, AsyncOperationExecutor executor)
public java.lang.String getName()
MongoDatabase
getName
in interface MongoDatabase
public CodecRegistry getCodecRegistry()
MongoDatabase
getCodecRegistry
in interface MongoDatabase
CodecRegistry
public ReadPreference getReadPreference()
MongoDatabase
getReadPreference
in interface MongoDatabase
ReadPreference
public WriteConcern getWriteConcern()
MongoDatabase
getWriteConcern
in interface MongoDatabase
WriteConcern
public ReadConcern getReadConcern()
MongoDatabase
getReadConcern
in interface MongoDatabase
ReadConcern
public MongoDatabase withCodecRegistry(CodecRegistry codecRegistry)
MongoDatabase
withCodecRegistry
in interface MongoDatabase
codecRegistry
- the new CodecRegistry
for the databasepublic MongoDatabase withReadPreference(ReadPreference readPreference)
MongoDatabase
withReadPreference
in interface MongoDatabase
readPreference
- the new ReadPreference
for the databasepublic MongoDatabase withWriteConcern(WriteConcern writeConcern)
MongoDatabase
withWriteConcern
in interface MongoDatabase
writeConcern
- the new WriteConcern
for the databasepublic MongoDatabase withReadConcern(ReadConcern readConcern)
MongoDatabase
withReadConcern
in interface MongoDatabase
readConcern
- the new ReadConcern
for the databasepublic MongoIterable<java.lang.String> listCollectionNames()
MongoDatabase
listCollectionNames
in interface MongoDatabase
public MongoIterable<java.lang.String> listCollectionNames(ClientSession clientSession)
MongoDatabase
listCollectionNames
in interface MongoDatabase
clientSession
- the client session with which to associate this operationprivate MongoIterable<java.lang.String> createListCollectionNamesIterable(ClientSession clientSession)
public ListCollectionsIterable<Document> listCollections()
MongoDatabase
listCollections
in interface MongoDatabase
public <TResult> ListCollectionsIterable<TResult> listCollections(java.lang.Class<TResult> resultClass)
MongoDatabase
listCollections
in interface MongoDatabase
TResult
- the target document type of the iterable.resultClass
- the class to decode each document intopublic ListCollectionsIterable<Document> listCollections(ClientSession clientSession)
MongoDatabase
listCollections
in interface MongoDatabase
clientSession
- the client session with which to associate this operationpublic <TResult> ListCollectionsIterable<TResult> listCollections(ClientSession clientSession, java.lang.Class<TResult> resultClass)
MongoDatabase
listCollections
in interface MongoDatabase
TResult
- the target document type of the iterable.clientSession
- the client session with which to associate this operationresultClass
- the class to decode each document intoprivate <TResult> ListCollectionsIterable<TResult> createListCollectionsIterable(ClientSession clientSession, java.lang.Class<TResult> resultClass)
public MongoCollection<Document> getCollection(java.lang.String collectionName)
MongoDatabase
getCollection
in interface MongoDatabase
collectionName
- the name of the collection to returnMongoNamespace.checkCollectionNameValidity(String)
public <TDocument> MongoCollection<TDocument> getCollection(java.lang.String collectionName, java.lang.Class<TDocument> documentClass)
MongoDatabase
getCollection
in interface MongoDatabase
TDocument
- the type of the class to use instead of Document
.collectionName
- the name of the collection to returndocumentClass
- the default class to cast any documents returned from the database into.public void runCommand(Bson command, SingleResultCallback<Document> callback)
MongoDatabase
ReadPreference.primary()
.runCommand
in interface MongoDatabase
command
- the command to be runcallback
- the callback that is passed the command resultpublic void runCommand(Bson command, ReadPreference readPreference, SingleResultCallback<Document> callback)
MongoDatabase
runCommand
in interface MongoDatabase
command
- the command to be runreadPreference
- the ReadPreference
to be used when executing the commandcallback
- the callback that is passed the command resultpublic <TResult> void runCommand(Bson command, java.lang.Class<TResult> resultClass, SingleResultCallback<TResult> callback)
MongoDatabase
ReadPreference.primary()
.runCommand
in interface MongoDatabase
TResult
- the type of the class to use instead of Document
.command
- the command to be runresultClass
- the default class to cast any documents returned from the database into.callback
- the callback that is passed the command resultpublic <TResult> void runCommand(Bson command, ReadPreference readPreference, java.lang.Class<TResult> resultClass, SingleResultCallback<TResult> callback)
MongoDatabase
runCommand
in interface MongoDatabase
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 commandresultClass
- the default class to cast any documents returned from the database into.callback
- the callback that is passed the command resultpublic void runCommand(ClientSession clientSession, Bson command, SingleResultCallback<Document> callback)
MongoDatabase
ReadPreference.primary()
.runCommand
in interface MongoDatabase
clientSession
- the client session with which to associate this operationcommand
- the command to be runcallback
- the callback that is passed the command resultpublic void runCommand(ClientSession clientSession, Bson command, ReadPreference readPreference, SingleResultCallback<Document> callback)
MongoDatabase
runCommand
in interface MongoDatabase
clientSession
- the client session with which to associate this operationcommand
- the command to be runreadPreference
- the ReadPreference
to be used when executing the commandcallback
- the callback that is passed the command resultpublic <TResult> void runCommand(ClientSession clientSession, Bson command, java.lang.Class<TResult> resultClass, SingleResultCallback<TResult> callback)
MongoDatabase
ReadPreference.primary()
.runCommand
in interface MongoDatabase
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 runresultClass
- the default class to cast any documents returned from the database into.callback
- the callback that is passed the command resultpublic <TResult> void runCommand(ClientSession clientSession, Bson command, ReadPreference readPreference, java.lang.Class<TResult> resultClass, SingleResultCallback<TResult> callback)
MongoDatabase
runCommand
in interface MongoDatabase
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 commandresultClass
- the default class to cast any documents returned from the database into.callback
- the callback that is passed the command resultprivate <TResult> void executeCommand(ClientSession clientSession, Bson command, ReadPreference readPreference, java.lang.Class<TResult> resultClass, SingleResultCallback<TResult> callback)
public void drop(SingleResultCallback<java.lang.Void> callback)
MongoDatabase
drop
in interface MongoDatabase
callback
- the callback that is completed once the database has been droppedpublic void drop(ClientSession clientSession, SingleResultCallback<java.lang.Void> callback)
MongoDatabase
drop
in interface MongoDatabase
clientSession
- the client session with which to associate this operationcallback
- the callback that is completed once the database has been droppedprivate void executeDrop(ClientSession clientSession, SingleResultCallback<java.lang.Void> callback)
public void createCollection(java.lang.String collectionName, SingleResultCallback<java.lang.Void> callback)
MongoDatabase
createCollection
in interface MongoDatabase
collectionName
- the name for the new collection to createcallback
- the callback that is completed once the collection has been createdpublic void createCollection(java.lang.String collectionName, CreateCollectionOptions createCollectionOptions, SingleResultCallback<java.lang.Void> callback)
MongoDatabase
createCollection
in interface MongoDatabase
collectionName
- the name for the new collection to createcreateCollectionOptions
- various options for creating the collectioncallback
- the callback that is completed once the collection has been createdpublic void createCollection(ClientSession clientSession, java.lang.String collectionName, SingleResultCallback<java.lang.Void> callback)
MongoDatabase
createCollection
in interface MongoDatabase
clientSession
- the client session with which to associate this operationcollectionName
- the name for the new collection to createcallback
- the callback that is completed once the collection has been createdpublic void createCollection(ClientSession clientSession, java.lang.String collectionName, CreateCollectionOptions options, SingleResultCallback<java.lang.Void> callback)
MongoDatabase
createCollection
in interface MongoDatabase
clientSession
- the client session with which to associate this operationcollectionName
- the name for the new collection to createoptions
- various options for creating the collectioncallback
- the callback that is completed once the collection has been createdprivate void executeCreateCollection(ClientSession clientSession, java.lang.String collectionName, CreateCollectionOptions options, SingleResultCallback<java.lang.Void> callback)
public void createView(java.lang.String viewName, java.lang.String viewOn, java.util.List<? extends Bson> pipeline, SingleResultCallback<java.lang.Void> callback)
MongoDatabase
createView
in interface MongoDatabase
viewName
- the name of the view to createviewOn
- the backing collection/view for the viewpipeline
- the pipeline that defines the viewcallback
- the callback that is completed once the collection has been createdpublic void createView(java.lang.String viewName, java.lang.String viewOn, java.util.List<? extends Bson> pipeline, CreateViewOptions createViewOptions, SingleResultCallback<java.lang.Void> callback)
MongoDatabase
createView
in interface MongoDatabase
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 viewcallback
- the callback that is completed once the collection has been createdpublic void createView(ClientSession clientSession, java.lang.String viewName, java.lang.String viewOn, java.util.List<? extends Bson> pipeline, SingleResultCallback<java.lang.Void> callback)
MongoDatabase
createView
in interface MongoDatabase
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 viewcallback
- the callback that is completed once the collection has been createdpublic void createView(ClientSession clientSession, java.lang.String viewName, java.lang.String viewOn, java.util.List<? extends Bson> pipeline, CreateViewOptions createViewOptions, SingleResultCallback<java.lang.Void> callback)
MongoDatabase
createView
in interface MongoDatabase
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 viewcallback
- the callback that is completed once the collection has been createdprivate void executeCreateView(ClientSession clientSession, java.lang.String viewName, java.lang.String viewOn, java.util.List<? extends Bson> pipeline, CreateViewOptions createViewOptions, SingleResultCallback<java.lang.Void> callback)
private java.util.List<BsonDocument> createBsonDocumentList(java.util.List<? extends Bson> pipeline)
private BsonDocument toBsonDocument(Bson document)