TDocument
- The type that this collection will encode documents from and decode documents to.@ThreadSafe public interface MongoCollection<TDocument>
Note: Additions to this interface will not be considered to break binary compatibility.
MongoCollection is generic allowing for different types to represent documents. Any custom classes must have a
Codec
registered in the CodecRegistry
. The default CodecRegistry
includes built-in support for:
BsonDocument
, Document
and DBObject
.
Modifier and Type | Method and Description |
---|---|
AggregateIterable<TDocument> |
aggregate(ClientSession clientSession,
java.util.List<? extends Bson> pipeline)
Aggregates documents according to the specified aggregation pipeline.
|
<TResult> AggregateIterable<TResult> |
aggregate(ClientSession clientSession,
java.util.List<? extends Bson> pipeline,
java.lang.Class<TResult> resultClass)
Aggregates documents according to the specified aggregation pipeline.
|
AggregateIterable<TDocument> |
aggregate(java.util.List<? extends Bson> pipeline)
Aggregates documents according to the specified aggregation pipeline.
|
<TResult> AggregateIterable<TResult> |
aggregate(java.util.List<? extends Bson> pipeline,
java.lang.Class<TResult> resultClass)
Aggregates documents according to the specified aggregation pipeline.
|
BulkWriteResult |
bulkWrite(ClientSession clientSession,
java.util.List<? extends WriteModel<? extends TDocument>> requests)
Executes a mix of inserts, updates, replaces, and deletes.
|
BulkWriteResult |
bulkWrite(ClientSession clientSession,
java.util.List<? extends WriteModel<? extends TDocument>> requests,
BulkWriteOptions options)
Executes a mix of inserts, updates, replaces, and deletes.
|
BulkWriteResult |
bulkWrite(java.util.List<? extends WriteModel<? extends TDocument>> requests)
Executes a mix of inserts, updates, replaces, and deletes.
|
BulkWriteResult |
bulkWrite(java.util.List<? extends WriteModel<? extends TDocument>> requests,
BulkWriteOptions options)
Executes a mix of inserts, updates, replaces, and deletes.
|
long |
count()
Counts the number of documents in the collection.
|
long |
count(Bson filter)
Counts the number of documents in the collection according to the given options.
|
long |
count(Bson filter,
CountOptions options)
Counts the number of documents in the collection according to the given options.
|
long |
count(ClientSession clientSession)
Counts the number of documents in the collection.
|
long |
count(ClientSession clientSession,
Bson filter)
Counts the number of documents in the collection according to the given options.
|
long |
count(ClientSession clientSession,
Bson filter,
CountOptions options)
Counts the number of documents in the collection according to the given options.
|
java.lang.String |
createIndex(Bson keys)
Create an index with the given keys.
|
java.lang.String |
createIndex(Bson keys,
IndexOptions indexOptions)
Create an index with the given keys and options.
|
java.lang.String |
createIndex(ClientSession clientSession,
Bson keys)
Create an index with the given keys.
|
java.lang.String |
createIndex(ClientSession clientSession,
Bson keys,
IndexOptions indexOptions)
Create an index with the given keys and options.
|
java.util.List<java.lang.String> |
createIndexes(ClientSession clientSession,
java.util.List<IndexModel> indexes)
Create multiple indexes.
|
java.util.List<java.lang.String> |
createIndexes(ClientSession clientSession,
java.util.List<IndexModel> indexes,
CreateIndexOptions createIndexOptions)
Create multiple indexes.
|
java.util.List<java.lang.String> |
createIndexes(java.util.List<IndexModel> indexes)
Create multiple indexes.
|
java.util.List<java.lang.String> |
createIndexes(java.util.List<IndexModel> indexes,
CreateIndexOptions createIndexOptions)
Create multiple indexes.
|
DeleteResult |
deleteMany(Bson filter)
Removes all documents from the collection that match the given query filter.
|
DeleteResult |
deleteMany(Bson filter,
DeleteOptions options)
Removes all documents from the collection that match the given query filter.
|
DeleteResult |
deleteMany(ClientSession clientSession,
Bson filter)
Removes all documents from the collection that match the given query filter.
|
DeleteResult |
deleteMany(ClientSession clientSession,
Bson filter,
DeleteOptions options)
Removes all documents from the collection that match the given query filter.
|
DeleteResult |
deleteOne(Bson filter)
Removes at most one document from the collection that matches the given filter.
|
DeleteResult |
deleteOne(Bson filter,
DeleteOptions options)
Removes at most one document from the collection that matches the given filter.
|
DeleteResult |
deleteOne(ClientSession clientSession,
Bson filter)
Removes at most one document from the collection that matches the given filter.
|
DeleteResult |
deleteOne(ClientSession clientSession,
Bson filter,
DeleteOptions options)
Removes at most one document from the collection that matches the given filter.
|
<TResult> DistinctIterable<TResult> |
distinct(ClientSession clientSession,
java.lang.String fieldName,
Bson filter,
java.lang.Class<TResult> resultClass)
Gets the distinct values of the specified field name.
|
<TResult> DistinctIterable<TResult> |
distinct(ClientSession clientSession,
java.lang.String fieldName,
java.lang.Class<TResult> resultClass)
Gets the distinct values of the specified field name.
|
<TResult> DistinctIterable<TResult> |
distinct(java.lang.String fieldName,
Bson filter,
java.lang.Class<TResult> resultClass)
Gets the distinct values of the specified field name.
|
<TResult> DistinctIterable<TResult> |
distinct(java.lang.String fieldName,
java.lang.Class<TResult> resultClass)
Gets the distinct values of the specified field name.
|
void |
drop()
Drops this collection from the Database.
|
void |
drop(ClientSession clientSession)
Drops this collection from the Database.
|
void |
dropIndex(Bson keys)
Drops the index given the keys used to create it.
|
void |
dropIndex(Bson keys,
DropIndexOptions dropIndexOptions)
Drops the index given the keys used to create it.
|
void |
dropIndex(ClientSession clientSession,
Bson keys)
Drops the index given the keys used to create it.
|
void |
dropIndex(ClientSession clientSession,
Bson keys,
DropIndexOptions dropIndexOptions)
Drops the index given the keys used to create it.
|
void |
dropIndex(ClientSession clientSession,
java.lang.String indexName)
Drops the index given its name.
|
void |
dropIndex(ClientSession clientSession,
java.lang.String indexName,
DropIndexOptions dropIndexOptions)
Drops the index given its name.
|
void |
dropIndex(java.lang.String indexName)
Drops the index given its name.
|
void |
dropIndex(java.lang.String indexName,
DropIndexOptions dropIndexOptions)
Drops the index given its name.
|
void |
dropIndexes()
Drop all the indexes on this collection, except for the default on _id.
|
void |
dropIndexes(ClientSession clientSession)
Drop all the indexes on this collection, except for the default on _id.
|
void |
dropIndexes(ClientSession clientSession,
DropIndexOptions dropIndexOptions)
Drop all the indexes on this collection, except for the default on _id.
|
void |
dropIndexes(DropIndexOptions dropIndexOptions)
Drop all the indexes on this collection, except for the default on _id.
|
FindIterable<TDocument> |
find()
Finds all documents in the collection.
|
FindIterable<TDocument> |
find(Bson filter)
Finds all documents in the collection.
|
<TResult> FindIterable<TResult> |
find(Bson filter,
java.lang.Class<TResult> resultClass)
Finds all documents in the collection.
|
<TResult> FindIterable<TResult> |
find(java.lang.Class<TResult> resultClass)
Finds all documents in the collection.
|
FindIterable<TDocument> |
find(ClientSession clientSession)
Finds all documents in the collection.
|
FindIterable<TDocument> |
find(ClientSession clientSession,
Bson filter)
Finds all documents in the collection.
|
<TResult> FindIterable<TResult> |
find(ClientSession clientSession,
Bson filter,
java.lang.Class<TResult> resultClass)
Finds all documents in the collection.
|
<TResult> FindIterable<TResult> |
find(ClientSession clientSession,
java.lang.Class<TResult> resultClass)
Finds all documents in the collection.
|
TDocument |
findOneAndDelete(Bson filter)
Atomically find a document and remove it.
|
TDocument |
findOneAndDelete(Bson filter,
FindOneAndDeleteOptions options)
Atomically find a document and remove it.
|
TDocument |
findOneAndDelete(ClientSession clientSession,
Bson filter)
Atomically find a document and remove it.
|
TDocument |
findOneAndDelete(ClientSession clientSession,
Bson filter,
FindOneAndDeleteOptions options)
Atomically find a document and remove it.
|
TDocument |
findOneAndReplace(Bson filter,
TDocument replacement)
Atomically find a document and replace it.
|
TDocument |
findOneAndReplace(Bson filter,
TDocument replacement,
FindOneAndReplaceOptions options)
Atomically find a document and replace it.
|
TDocument |
findOneAndReplace(ClientSession clientSession,
Bson filter,
TDocument replacement)
Atomically find a document and replace it.
|
TDocument |
findOneAndReplace(ClientSession clientSession,
Bson filter,
TDocument replacement,
FindOneAndReplaceOptions options)
Atomically find a document and replace it.
|
TDocument |
findOneAndUpdate(Bson filter,
Bson update)
Atomically find a document and update it.
|
TDocument |
findOneAndUpdate(Bson filter,
Bson update,
FindOneAndUpdateOptions options)
Atomically find a document and update it.
|
TDocument |
findOneAndUpdate(ClientSession clientSession,
Bson filter,
Bson update)
Atomically find a document and update it.
|
TDocument |
findOneAndUpdate(ClientSession clientSession,
Bson filter,
Bson update,
FindOneAndUpdateOptions options)
Atomically find a document and update it.
|
CodecRegistry |
getCodecRegistry()
Get the codec registry for the MongoCollection.
|
java.lang.Class<TDocument> |
getDocumentClass()
Get the class of documents stored in this collection.
|
MongoNamespace |
getNamespace()
Gets the namespace of this collection.
|
ReadConcern |
getReadConcern()
Get the read concern for the MongoCollection.
|
ReadPreference |
getReadPreference()
Get the read preference for the MongoCollection.
|
WriteConcern |
getWriteConcern()
Get the write concern for the MongoCollection.
|
void |
insertMany(ClientSession clientSession,
java.util.List<? extends TDocument> documents)
Inserts one or more documents.
|
void |
insertMany(ClientSession clientSession,
java.util.List<? extends TDocument> documents,
InsertManyOptions options)
Inserts one or more documents.
|
void |
insertMany(java.util.List<? extends TDocument> documents)
Inserts one or more documents.
|
void |
insertMany(java.util.List<? extends TDocument> documents,
InsertManyOptions options)
Inserts one or more documents.
|
void |
insertOne(ClientSession clientSession,
TDocument document)
Inserts the provided document.
|
void |
insertOne(ClientSession clientSession,
TDocument document,
InsertOneOptions options)
Inserts the provided document.
|
void |
insertOne(TDocument document)
Inserts the provided document.
|
void |
insertOne(TDocument document,
InsertOneOptions options)
Inserts the provided document.
|
ListIndexesIterable<Document> |
listIndexes()
Get all the indexes in this collection.
|
<TResult> ListIndexesIterable<TResult> |
listIndexes(java.lang.Class<TResult> resultClass)
Get all the indexes in this collection.
|
ListIndexesIterable<Document> |
listIndexes(ClientSession clientSession)
Get all the indexes in this collection.
|
<TResult> ListIndexesIterable<TResult> |
listIndexes(ClientSession clientSession,
java.lang.Class<TResult> resultClass)
Get all the indexes in this collection.
|
MapReduceIterable<TDocument> |
mapReduce(ClientSession clientSession,
java.lang.String mapFunction,
java.lang.String reduceFunction)
Aggregates documents according to the specified map-reduce function.
|
<TResult> MapReduceIterable<TResult> |
mapReduce(ClientSession clientSession,
java.lang.String mapFunction,
java.lang.String reduceFunction,
java.lang.Class<TResult> resultClass)
Aggregates documents according to the specified map-reduce function.
|
MapReduceIterable<TDocument> |
mapReduce(java.lang.String mapFunction,
java.lang.String reduceFunction)
Aggregates documents according to the specified map-reduce function.
|
<TResult> MapReduceIterable<TResult> |
mapReduce(java.lang.String mapFunction,
java.lang.String reduceFunction,
java.lang.Class<TResult> resultClass)
Aggregates documents according to the specified map-reduce function.
|
void |
renameCollection(ClientSession clientSession,
MongoNamespace newCollectionNamespace)
Rename the collection with oldCollectionName to the newCollectionName.
|
void |
renameCollection(ClientSession clientSession,
MongoNamespace newCollectionNamespace,
RenameCollectionOptions renameCollectionOptions)
Rename the collection with oldCollectionName to the newCollectionName.
|
void |
renameCollection(MongoNamespace newCollectionNamespace)
Rename the collection with oldCollectionName to the newCollectionName.
|
void |
renameCollection(MongoNamespace newCollectionNamespace,
RenameCollectionOptions renameCollectionOptions)
Rename the collection with oldCollectionName to the newCollectionName.
|
UpdateResult |
replaceOne(Bson filter,
TDocument replacement)
Replace a document in the collection according to the specified arguments.
|
UpdateResult |
replaceOne(Bson filter,
TDocument replacement,
UpdateOptions updateOptions)
Replace a document in the collection according to the specified arguments.
|
UpdateResult |
replaceOne(ClientSession clientSession,
Bson filter,
TDocument replacement)
Replace a document in the collection according to the specified arguments.
|
UpdateResult |
replaceOne(ClientSession clientSession,
Bson filter,
TDocument replacement,
UpdateOptions updateOptions)
Replace a document in the collection according to the specified arguments.
|
UpdateResult |
updateMany(Bson filter,
Bson update)
Update all documents in the collection according to the specified arguments.
|
UpdateResult |
updateMany(Bson filter,
Bson update,
UpdateOptions updateOptions)
Update all documents in the collection according to the specified arguments.
|
UpdateResult |
updateMany(ClientSession clientSession,
Bson filter,
Bson update)
Update all documents in the collection according to the specified arguments.
|
UpdateResult |
updateMany(ClientSession clientSession,
Bson filter,
Bson update,
UpdateOptions updateOptions)
Update all documents in the collection according to the specified arguments.
|
UpdateResult |
updateOne(Bson filter,
Bson update)
Update a single document in the collection according to the specified arguments.
|
UpdateResult |
updateOne(Bson filter,
Bson update,
UpdateOptions updateOptions)
Update a single document in the collection according to the specified arguments.
|
UpdateResult |
updateOne(ClientSession clientSession,
Bson filter,
Bson update)
Update a single document in the collection according to the specified arguments.
|
UpdateResult |
updateOne(ClientSession clientSession,
Bson filter,
Bson update,
UpdateOptions updateOptions)
Update a single document in the collection according to the specified arguments.
|
ChangeStreamIterable<TDocument> |
watch()
Creates a change stream for this collection.
|
<TResult> ChangeStreamIterable<TResult> |
watch(java.lang.Class<TResult> resultClass)
Creates a change stream for this collection.
|
ChangeStreamIterable<TDocument> |
watch(ClientSession clientSession)
Creates a change stream for this collection.
|
<TResult> ChangeStreamIterable<TResult> |
watch(ClientSession clientSession,
java.lang.Class<TResult> resultClass)
Creates a change stream for this collection.
|
ChangeStreamIterable<TDocument> |
watch(ClientSession clientSession,
java.util.List<? extends Bson> pipeline)
Creates a change stream for this collection.
|
<TResult> ChangeStreamIterable<TResult> |
watch(ClientSession clientSession,
java.util.List<? extends Bson> pipeline,
java.lang.Class<TResult> resultClass)
Creates a change stream for this collection.
|
ChangeStreamIterable<TDocument> |
watch(java.util.List<? extends Bson> pipeline)
Creates a change stream for this collection.
|
<TResult> ChangeStreamIterable<TResult> |
watch(java.util.List<? extends Bson> pipeline,
java.lang.Class<TResult> resultClass)
Creates a change stream for this collection.
|
MongoCollection<TDocument> |
withCodecRegistry(CodecRegistry codecRegistry)
Create a new MongoCollection instance with a different codec registry.
|
<NewTDocument> |
withDocumentClass(java.lang.Class<NewTDocument> clazz)
Create a new MongoCollection instance with a different default class to cast any documents returned from the database into..
|
MongoCollection<TDocument> |
withReadConcern(ReadConcern readConcern)
Create a new MongoCollection instance with a different read concern.
|
MongoCollection<TDocument> |
withReadPreference(ReadPreference readPreference)
Create a new MongoCollection instance with a different read preference.
|
MongoCollection<TDocument> |
withWriteConcern(WriteConcern writeConcern)
Create a new MongoCollection instance with a different write concern.
|
MongoNamespace getNamespace()
java.lang.Class<TDocument> getDocumentClass()
CodecRegistry getCodecRegistry()
CodecRegistry
ReadPreference getReadPreference()
ReadPreference
WriteConcern getWriteConcern()
WriteConcern
ReadConcern getReadConcern()
ReadConcern
<NewTDocument> MongoCollection<NewTDocument> withDocumentClass(java.lang.Class<NewTDocument> clazz)
NewTDocument
- The type that the new collection will encode documents from and decode documents toclazz
- the default class to cast any documents returned from the database into.MongoCollection<TDocument> withCodecRegistry(CodecRegistry codecRegistry)
codecRegistry
- the new CodecRegistry
for the collectionMongoCollection<TDocument> withReadPreference(ReadPreference readPreference)
readPreference
- the new ReadPreference
for the collectionMongoCollection<TDocument> withWriteConcern(WriteConcern writeConcern)
writeConcern
- the new WriteConcern
for the collectionMongoCollection<TDocument> withReadConcern(ReadConcern readConcern)
readConcern
- the new ReadConcern
for the collectionlong count()
long count(Bson filter)
filter
- the query filterlong count(Bson filter, CountOptions options)
filter
- the query filteroptions
- the options describing the countlong count(ClientSession clientSession)
clientSession
- the client session with which to associate this operationlong count(ClientSession clientSession, Bson filter)
clientSession
- the client session with which to associate this operationfilter
- the query filterlong count(ClientSession clientSession, Bson filter, CountOptions options)
clientSession
- the client session with which to associate this operationfilter
- the query filteroptions
- the options describing the count<TResult> DistinctIterable<TResult> distinct(java.lang.String fieldName, java.lang.Class<TResult> resultClass)
TResult
- the target type of the iterable.fieldName
- the field nameresultClass
- the class to cast any distinct items into.<TResult> DistinctIterable<TResult> distinct(java.lang.String fieldName, Bson filter, java.lang.Class<TResult> resultClass)
TResult
- the target type of the iterable.fieldName
- the field namefilter
- the query filterresultClass
- the class to cast any distinct items into.<TResult> DistinctIterable<TResult> distinct(ClientSession clientSession, java.lang.String fieldName, java.lang.Class<TResult> resultClass)
TResult
- the target type of the iterable.clientSession
- the client session with which to associate this operationfieldName
- the field nameresultClass
- the class to cast any distinct items into.<TResult> DistinctIterable<TResult> distinct(ClientSession clientSession, java.lang.String fieldName, Bson filter, java.lang.Class<TResult> resultClass)
TResult
- the target type of the iterable.clientSession
- the client session with which to associate this operationfieldName
- the field namefilter
- the query filterresultClass
- the class to cast any distinct items into.FindIterable<TDocument> find()
<TResult> FindIterable<TResult> find(java.lang.Class<TResult> resultClass)
TResult
- the target document type of the iterable.resultClass
- the class to decode each document intoFindIterable<TDocument> find(Bson filter)
filter
- the query filter<TResult> FindIterable<TResult> find(Bson filter, java.lang.Class<TResult> resultClass)
TResult
- the target document type of the iterable.filter
- the query filterresultClass
- the class to decode each document intoFindIterable<TDocument> find(ClientSession clientSession)
<TResult> FindIterable<TResult> find(ClientSession clientSession, java.lang.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 intoFindIterable<TDocument> find(ClientSession clientSession, Bson filter)
<TResult> FindIterable<TResult> find(ClientSession clientSession, Bson filter, java.lang.Class<TResult> resultClass)
TResult
- the target document type of the iterable.clientSession
- the client session with which to associate this operationfilter
- the query filterresultClass
- the class to decode each document intoAggregateIterable<TDocument> aggregate(java.util.List<? extends Bson> pipeline)
pipeline
- the aggregation pipeline<TResult> AggregateIterable<TResult> aggregate(java.util.List<? extends Bson> pipeline, java.lang.Class<TResult> resultClass)
TResult
- the target document type of the iterable.pipeline
- the aggregation pipelineresultClass
- the class to decode each document intoAggregateIterable<TDocument> aggregate(ClientSession clientSession, java.util.List<? extends Bson> pipeline)
clientSession
- the client session with which to associate this operationpipeline
- the aggregation pipeline<TResult> AggregateIterable<TResult> aggregate(ClientSession clientSession, java.util.List<? extends Bson> pipeline, java.lang.Class<TResult> resultClass)
TResult
- the target document type of the iterable.clientSession
- the client session with which to associate this operationpipeline
- the aggregation pipelineresultClass
- the class to decode each document intoChangeStreamIterable<TDocument> watch()
<TResult> ChangeStreamIterable<TResult> watch(java.lang.Class<TResult> resultClass)
TResult
- the target document type of the iterable.resultClass
- the class to decode each document intoChangeStreamIterable<TDocument> watch(java.util.List<? extends Bson> pipeline)
pipeline
- the aggregation pipeline to apply to the change stream.<TResult> ChangeStreamIterable<TResult> watch(java.util.List<? extends Bson> pipeline, java.lang.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 intoChangeStreamIterable<TDocument> watch(ClientSession clientSession)
clientSession
- the client session with which to associate this operation<TResult> ChangeStreamIterable<TResult> watch(ClientSession clientSession, java.lang.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 intoChangeStreamIterable<TDocument> watch(ClientSession clientSession, java.util.List<? extends Bson> pipeline)
clientSession
- the client session with which to associate this operationpipeline
- the aggregation pipeline to apply to the change stream.<TResult> ChangeStreamIterable<TResult> watch(ClientSession clientSession, java.util.List<? extends Bson> pipeline, java.lang.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 intoMapReduceIterable<TDocument> mapReduce(java.lang.String mapFunction, java.lang.String reduceFunction)
mapFunction
- A JavaScript function that associates or "maps" a value with a key and emits the key and value pair.reduceFunction
- A JavaScript function that "reduces" to a single object all the values associated with a particular key.<TResult> MapReduceIterable<TResult> mapReduce(java.lang.String mapFunction, java.lang.String reduceFunction, java.lang.Class<TResult> resultClass)
TResult
- the target document type of the iterable.mapFunction
- A JavaScript function that associates or "maps" a value with a key and emits the key and value pair.reduceFunction
- A JavaScript function that "reduces" to a single object all the values associated with a particular key.resultClass
- the class to decode each resulting document into.MapReduceIterable<TDocument> mapReduce(ClientSession clientSession, java.lang.String mapFunction, java.lang.String reduceFunction)
clientSession
- the client session with which to associate this operationmapFunction
- A JavaScript function that associates or "maps" a value with a key and emits the key and value pair.reduceFunction
- A JavaScript function that "reduces" to a single object all the values associated with a particular key.<TResult> MapReduceIterable<TResult> mapReduce(ClientSession clientSession, java.lang.String mapFunction, java.lang.String reduceFunction, java.lang.Class<TResult> resultClass)
TResult
- the target document type of the iterable.clientSession
- the client session with which to associate this operationmapFunction
- A JavaScript function that associates or "maps" a value with a key and emits the key and value pair.reduceFunction
- A JavaScript function that "reduces" to a single object all the values associated with a particular key.resultClass
- the class to decode each resulting document into.BulkWriteResult bulkWrite(java.util.List<? extends WriteModel<? extends TDocument>> requests)
requests
- the writes to executeMongoBulkWriteException
- if there's an exception in the bulk write operationMongoException
- if there's an exception running the operationBulkWriteResult bulkWrite(java.util.List<? extends WriteModel<? extends TDocument>> requests, BulkWriteOptions options)
requests
- the writes to executeoptions
- the options to apply to the bulk write operationMongoBulkWriteException
- if there's an exception in the bulk write operationMongoException
- if there's an exception running the operationBulkWriteResult bulkWrite(ClientSession clientSession, java.util.List<? extends WriteModel<? extends TDocument>> requests)
clientSession
- the client session with which to associate this operationrequests
- the writes to executeMongoBulkWriteException
- if there's an exception in the bulk write operationMongoException
- if there's an exception running the operationBulkWriteResult bulkWrite(ClientSession clientSession, java.util.List<? extends WriteModel<? extends TDocument>> requests, BulkWriteOptions options)
clientSession
- the client session with which to associate this operationrequests
- the writes to executeoptions
- the options to apply to the bulk write operationMongoBulkWriteException
- if there's an exception in the bulk write operationMongoException
- if there's an exception running the operationvoid insertOne(TDocument document)
document
- the document to insertMongoWriteException
- if the write failed due some other failure specific to the insert commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failurevoid insertOne(TDocument document, InsertOneOptions options)
document
- the document to insertoptions
- the options to apply to the operationMongoWriteException
- if the write failed due some other failure specific to the insert commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoCommandException
- if the write failed due to document validation reasonsMongoException
- if the write failed due some other failurevoid insertOne(ClientSession clientSession, TDocument document)
clientSession
- the client session with which to associate this operationdocument
- the document to insertMongoWriteException
- if the write failed due some other failure specific to the insert commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failurevoid insertOne(ClientSession clientSession, TDocument document, InsertOneOptions options)
clientSession
- the client session with which to associate this operationdocument
- the document to insertoptions
- the options to apply to the operationMongoWriteException
- if the write failed due some other failure specific to the insert commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoCommandException
- if the write failed due to document validation reasonsMongoException
- if the write failed due some other failurevoid insertMany(java.util.List<? extends TDocument> documents)
bulkWrite
methoddocuments
- the documents to insertMongoBulkWriteException
- if there's an exception in the bulk write operationMongoException
- if the write failed due some other failurebulkWrite(java.util.List<? extends com.mongodb.client.model.WriteModel<? extends TDocument>>)
void insertMany(java.util.List<? extends TDocument> documents, InsertManyOptions options)
bulkWrite
methoddocuments
- the documents to insertoptions
- the options to apply to the operationDuplicateKeyException
- if the write failed to a duplicate unique keyWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failurevoid insertMany(ClientSession clientSession, java.util.List<? extends TDocument> documents)
bulkWrite
methodclientSession
- the client session with which to associate this operationdocuments
- the documents to insertMongoBulkWriteException
- if there's an exception in the bulk write operationMongoException
- if the write failed due some other failurebulkWrite(java.util.List<? extends com.mongodb.client.model.WriteModel<? extends TDocument>>)
void insertMany(ClientSession clientSession, java.util.List<? extends TDocument> documents, InsertManyOptions options)
bulkWrite
methodclientSession
- the client session with which to associate this operationdocuments
- the documents to insertoptions
- the options to apply to the operationDuplicateKeyException
- if the write failed to a duplicate unique keyWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failureDeleteResult deleteOne(Bson filter)
filter
- the query filter to apply the the delete operationMongoWriteException
- if the write failed due some other failure specific to the delete commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failureDeleteResult deleteOne(Bson filter, DeleteOptions options)
filter
- the query filter to apply the the delete operationoptions
- the options to apply to the delete operationMongoWriteException
- if the write failed due some other failure specific to the delete commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failureDeleteResult deleteOne(ClientSession clientSession, Bson filter)
clientSession
- the client session with which to associate this operationfilter
- the query filter to apply the the delete operationMongoWriteException
- if the write failed due some other failure specific to the delete commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failureDeleteResult deleteOne(ClientSession clientSession, Bson filter, DeleteOptions options)
clientSession
- the client session with which to associate this operationfilter
- the query filter to apply the the delete operationoptions
- the options to apply to the delete operationMongoWriteException
- if the write failed due some other failure specific to the delete commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failureDeleteResult deleteMany(Bson filter)
filter
- the query filter to apply the the delete operationMongoWriteException
- if the write failed due some other failure specific to the delete commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failureDeleteResult deleteMany(Bson filter, DeleteOptions options)
filter
- the query filter to apply the the delete operationoptions
- the options to apply to the delete operationMongoWriteException
- if the write failed due some other failure specific to the delete commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failureDeleteResult deleteMany(ClientSession clientSession, Bson filter)
clientSession
- the client session with which to associate this operationfilter
- the query filter to apply the the delete operationMongoWriteException
- if the write failed due some other failure specific to the delete commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failureDeleteResult deleteMany(ClientSession clientSession, Bson filter, DeleteOptions options)
clientSession
- the client session with which to associate this operationfilter
- the query filter to apply the the delete operationoptions
- the options to apply to the delete operationMongoWriteException
- if the write failed due some other failure specific to the delete commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failureUpdateResult replaceOne(Bson filter, TDocument replacement)
filter
- the query filter to apply the the replace operationreplacement
- the replacement documentMongoWriteException
- if the write failed due some other failure specific to the replace commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failureUpdateResult replaceOne(Bson filter, TDocument replacement, UpdateOptions updateOptions)
filter
- the query filter to apply the the replace operationreplacement
- the replacement documentupdateOptions
- the options to apply to the replace operationMongoWriteException
- if the write failed due some other failure specific to the replace commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failureUpdateResult replaceOne(ClientSession clientSession, Bson filter, TDocument replacement)
clientSession
- the client session with which to associate this operationfilter
- the query filter to apply the the replace operationreplacement
- the replacement documentMongoWriteException
- if the write failed due some other failure specific to the replace commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failureUpdateResult replaceOne(ClientSession clientSession, Bson filter, TDocument replacement, UpdateOptions updateOptions)
clientSession
- the client session with which to associate this operationfilter
- the query filter to apply the the replace operationreplacement
- the replacement documentupdateOptions
- the options to apply to the replace operationMongoWriteException
- if the write failed due some other failure specific to the replace commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failureUpdateResult updateOne(Bson filter, Bson update)
filter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include only update operators.MongoWriteException
- if the write failed due some other failure specific to the update commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failureUpdateResult updateOne(Bson filter, Bson update, UpdateOptions updateOptions)
filter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include only update operators.updateOptions
- the options to apply to the update operationMongoWriteException
- if the write failed due some other failure specific to the update commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failureUpdateResult updateOne(ClientSession clientSession, Bson filter, Bson update)
clientSession
- the client session with which to associate this operationfilter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include only update operators.MongoWriteException
- if the write failed due some other failure specific to the update commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failureUpdateResult updateOne(ClientSession clientSession, Bson filter, Bson update, UpdateOptions updateOptions)
clientSession
- the client session with which to associate this operationfilter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include only update operators.updateOptions
- the options to apply to the update operationMongoWriteException
- if the write failed due some other failure specific to the update commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failureUpdateResult updateMany(Bson filter, Bson update)
filter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include only update operators.MongoWriteException
- if the write failed due some other failure specific to the update commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failureUpdateResult updateMany(Bson filter, Bson update, UpdateOptions updateOptions)
filter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include only update operators.updateOptions
- the options to apply to the update operationMongoWriteException
- if the write failed due some other failure specific to the update commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failureUpdateResult updateMany(ClientSession clientSession, Bson filter, Bson update)
clientSession
- the client session with which to associate this operationfilter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include only update operators.MongoWriteException
- if the write failed due some other failure specific to the update commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failureUpdateResult updateMany(ClientSession clientSession, Bson filter, Bson update, UpdateOptions updateOptions)
clientSession
- the client session with which to associate this operationfilter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include only update operators.updateOptions
- the options to apply to the update operationMongoWriteException
- if the write failed due some other failure specific to the update commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failureTDocument findOneAndDelete(Bson filter)
filter
- the query filter to find the document withTDocument findOneAndDelete(Bson filter, FindOneAndDeleteOptions options)
filter
- the query filter to find the document withoptions
- the options to apply to the operationTDocument findOneAndDelete(ClientSession clientSession, Bson filter)
clientSession
- the client session with which to associate this operationfilter
- the query filter to find the document withTDocument findOneAndDelete(ClientSession clientSession, Bson filter, FindOneAndDeleteOptions options)
clientSession
- the client session with which to associate this operationfilter
- the query filter to find the document withoptions
- the options to apply to the operationTDocument findOneAndReplace(Bson filter, TDocument replacement)
filter
- the query filter to apply the the replace operationreplacement
- the replacement documentreturnOriginal
property, this will either be the
document as it was before the update or as it is after the update. If no documents matched the query filter, then null will be
returnedTDocument findOneAndReplace(Bson filter, TDocument replacement, FindOneAndReplaceOptions options)
filter
- the query filter to apply the the replace operationreplacement
- the replacement documentoptions
- the options to apply to the operationreturnOriginal
property, this will either be the
document as it was before the update or as it is after the update. If no documents matched the query filter, then null will be
returnedTDocument findOneAndReplace(ClientSession clientSession, Bson filter, TDocument replacement)
clientSession
- the client session with which to associate this operationfilter
- the query filter to apply the the replace operationreplacement
- the replacement documentreturnOriginal
property, this will either be the
document as it was before the update or as it is after the update. If no documents matched the query filter, then null will be
returnedTDocument findOneAndReplace(ClientSession clientSession, Bson filter, TDocument replacement, FindOneAndReplaceOptions options)
clientSession
- the client session with which to associate this operationfilter
- the query filter to apply the the replace operationreplacement
- the replacement documentoptions
- the options to apply to the operationreturnOriginal
property, this will either be the
document as it was before the update or as it is after the update. If no documents matched the query filter, then null will be
returnedTDocument findOneAndUpdate(Bson filter, Bson update)
filter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include only update operators.TDocument findOneAndUpdate(Bson filter, Bson update, FindOneAndUpdateOptions options)
filter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include only update operators.options
- the options to apply to the operationreturnOriginal
property, this will either be the
document as it was before the update or as it is after the update. If no documents matched the query filter, then null will be
returnedTDocument findOneAndUpdate(ClientSession clientSession, Bson filter, Bson update)
clientSession
- the client session with which to associate this operationfilter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include only update operators.TDocument findOneAndUpdate(ClientSession clientSession, Bson filter, Bson update, FindOneAndUpdateOptions options)
clientSession
- the client session with which to associate this operationfilter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include only update operators.options
- the options to apply to the operationreturnOriginal
property, this will either be the
document as it was before the update or as it is after the update. If no documents matched the query filter, then null will be
returnedvoid drop()
void drop(ClientSession clientSession)
clientSession
- the client session with which to associate this operationjava.lang.String createIndex(Bson keys)
keys
- an object describing the index key(s), which may not be null.java.lang.String createIndex(Bson keys, IndexOptions indexOptions)
keys
- an object describing the index key(s), which may not be null.indexOptions
- the options for the indexjava.lang.String createIndex(ClientSession clientSession, Bson keys)
clientSession
- the client session with which to associate this operationkeys
- an object describing the index key(s), which may not be null.java.lang.String createIndex(ClientSession clientSession, Bson keys, IndexOptions indexOptions)
clientSession
- the client session with which to associate this operationkeys
- an object describing the index key(s), which may not be null.indexOptions
- the options for the indexjava.util.List<java.lang.String> createIndexes(java.util.List<IndexModel> indexes)
indexes
- the list of indexesjava.util.List<java.lang.String> createIndexes(java.util.List<IndexModel> indexes, CreateIndexOptions createIndexOptions)
indexes
- the list of indexescreateIndexOptions
- options to use when creating indexesjava.util.List<java.lang.String> createIndexes(ClientSession clientSession, java.util.List<IndexModel> indexes)
clientSession
- the client session with which to associate this operationindexes
- the list of indexesjava.util.List<java.lang.String> createIndexes(ClientSession clientSession, java.util.List<IndexModel> indexes, CreateIndexOptions createIndexOptions)
clientSession
- the client session with which to associate this operationindexes
- the list of indexescreateIndexOptions
- options to use when creating indexesListIndexesIterable<Document> listIndexes()
<TResult> ListIndexesIterable<TResult> listIndexes(java.lang.Class<TResult> resultClass)
TResult
- the target document type of the iterable.resultClass
- the class to decode each document intoListIndexesIterable<Document> listIndexes(ClientSession clientSession)
clientSession
- the client session with which to associate this operation<TResult> ListIndexesIterable<TResult> listIndexes(ClientSession clientSession, java.lang.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 intovoid dropIndex(java.lang.String indexName)
indexName
- the name of the index to removevoid dropIndex(java.lang.String indexName, DropIndexOptions dropIndexOptions)
indexName
- the name of the index to removedropIndexOptions
- the options to use when dropping indexesvoid dropIndex(Bson keys)
keys
- the keys of the index to removevoid dropIndex(Bson keys, DropIndexOptions dropIndexOptions)
keys
- the keys of the index to removedropIndexOptions
- the options to use when dropping indexesvoid dropIndex(ClientSession clientSession, java.lang.String indexName)
clientSession
- the client session with which to associate this operationindexName
- the name of the index to removevoid dropIndex(ClientSession clientSession, Bson keys)
clientSession
- the client session with which to associate this operationkeys
- the keys of the index to removevoid dropIndex(ClientSession clientSession, java.lang.String indexName, DropIndexOptions dropIndexOptions)
clientSession
- the client session with which to associate this operationindexName
- the name of the index to removedropIndexOptions
- the options to use when dropping indexesvoid dropIndex(ClientSession clientSession, Bson keys, DropIndexOptions dropIndexOptions)
clientSession
- the client session with which to associate this operationkeys
- the keys of the index to removedropIndexOptions
- the options to use when dropping indexesvoid dropIndexes()
void dropIndexes(ClientSession clientSession)
clientSession
- the client session with which to associate this operationvoid dropIndexes(DropIndexOptions dropIndexOptions)
dropIndexOptions
- the options to use when dropping indexesvoid dropIndexes(ClientSession clientSession, DropIndexOptions dropIndexOptions)
clientSession
- the client session with which to associate this operationdropIndexOptions
- the options to use when dropping indexesvoid renameCollection(MongoNamespace newCollectionNamespace)
newCollectionNamespace
- the namespace the collection will be renamed toMongoServerException
- if you provide a newCollectionName that is the name of an existing collection, or if the
oldCollectionName is the name of a collection that doesn't existvoid renameCollection(MongoNamespace newCollectionNamespace, RenameCollectionOptions renameCollectionOptions)
newCollectionNamespace
- the name the collection will be renamed torenameCollectionOptions
- the options for renaming a collectionMongoServerException
- if you provide a newCollectionName that is the name of an existing collection and dropTarget
is false, or if the oldCollectionName is the name of a collection that doesn't existvoid renameCollection(ClientSession clientSession, MongoNamespace newCollectionNamespace)
clientSession
- the client session with which to associate this operationnewCollectionNamespace
- the namespace the collection will be renamed toMongoServerException
- if you provide a newCollectionName that is the name of an existing collection, or if the
oldCollectionName is the name of a collection that doesn't existvoid renameCollection(ClientSession clientSession, MongoNamespace newCollectionNamespace, RenameCollectionOptions renameCollectionOptions)
clientSession
- the client session with which to associate this operationnewCollectionNamespace
- the name the collection will be renamed torenameCollectionOptions
- the options for renaming a collectionMongoServerException
- if you provide a newCollectionName that is the name of an existing collection and dropTarget
is false, or if the oldCollectionName is the name of a collection that doesn't exist