Interface MongoCollection<TDocument>
-
- Type Parameters:
TDocument
- The type that this collection will encode documents from and decode documents to.
@ThreadSafe public interface MongoCollection<TDocument>
The MongoCollection interface.Note: Additions to this interface will not be considered to break binary compatibility.
- Since:
- 1.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description AggregatePublisher<TDocument>
aggregate(ClientSession clientSession, List<? extends Bson> pipeline)
Aggregates documents according to the specified aggregation pipeline.<TResult> AggregatePublisher<TResult>
aggregate(ClientSession clientSession, List<? extends Bson> pipeline, Class<TResult> clazz)
Aggregates documents according to the specified aggregation pipeline.AggregatePublisher<TDocument>
aggregate(List<? extends Bson> pipeline)
Aggregates documents according to the specified aggregation pipeline.<TResult> AggregatePublisher<TResult>
aggregate(List<? extends Bson> pipeline, Class<TResult> clazz)
Aggregates documents according to the specified aggregation pipeline.org.reactivestreams.Publisher<BulkWriteResult>
bulkWrite(ClientSession clientSession, List<? extends WriteModel<? extends TDocument>> requests)
Executes a mix of inserts, updates, replaces, and deletes.org.reactivestreams.Publisher<BulkWriteResult>
bulkWrite(ClientSession clientSession, List<? extends WriteModel<? extends TDocument>> requests, BulkWriteOptions options)
Executes a mix of inserts, updates, replaces, and deletes.org.reactivestreams.Publisher<BulkWriteResult>
bulkWrite(List<? extends WriteModel<? extends TDocument>> requests)
Executes a mix of inserts, updates, replaces, and deletes.org.reactivestreams.Publisher<BulkWriteResult>
bulkWrite(List<? extends WriteModel<? extends TDocument>> requests, BulkWriteOptions options)
Executes a mix of inserts, updates, replaces, and deletes.org.reactivestreams.Publisher<Long>
countDocuments()
Counts the number of documents in the collection.org.reactivestreams.Publisher<Long>
countDocuments(ClientSession clientSession)
Counts the number of documents in the collection.org.reactivestreams.Publisher<Long>
countDocuments(ClientSession clientSession, Bson filter)
Counts the number of documents in the collection according to the given options.org.reactivestreams.Publisher<Long>
countDocuments(ClientSession clientSession, Bson filter, CountOptions options)
Counts the number of documents in the collection according to the given options.org.reactivestreams.Publisher<Long>
countDocuments(Bson filter)
Counts the number of documents in the collection according to the given options.org.reactivestreams.Publisher<Long>
countDocuments(Bson filter, CountOptions options)
Counts the number of documents in the collection according to the given options.org.reactivestreams.Publisher<String>
createIndex(ClientSession clientSession, Bson key)
Creates an index.org.reactivestreams.Publisher<String>
createIndex(ClientSession clientSession, Bson key, IndexOptions options)
Creates an index.org.reactivestreams.Publisher<String>
createIndex(Bson key)
Creates an index.org.reactivestreams.Publisher<String>
createIndex(Bson key, IndexOptions options)
Creates an index.org.reactivestreams.Publisher<String>
createIndexes(ClientSession clientSession, List<IndexModel> indexes)
Create multiple indexes.org.reactivestreams.Publisher<String>
createIndexes(ClientSession clientSession, List<IndexModel> indexes, CreateIndexOptions createIndexOptions)
Create multiple indexes.org.reactivestreams.Publisher<String>
createIndexes(List<IndexModel> indexes)
Create multiple indexes.org.reactivestreams.Publisher<String>
createIndexes(List<IndexModel> indexes, CreateIndexOptions createIndexOptions)
Create multiple indexes.org.reactivestreams.Publisher<DeleteResult>
deleteMany(ClientSession clientSession, Bson filter)
Removes all documents from the collection that match the given query filter.org.reactivestreams.Publisher<DeleteResult>
deleteMany(ClientSession clientSession, Bson filter, DeleteOptions options)
Removes all documents from the collection that match the given query filter.org.reactivestreams.Publisher<DeleteResult>
deleteMany(Bson filter)
Removes all documents from the collection that match the given query filter.org.reactivestreams.Publisher<DeleteResult>
deleteMany(Bson filter, DeleteOptions options)
Removes all documents from the collection that match the given query filter.org.reactivestreams.Publisher<DeleteResult>
deleteOne(ClientSession clientSession, Bson filter)
Removes at most one document from the collection that matches the given filter.org.reactivestreams.Publisher<DeleteResult>
deleteOne(ClientSession clientSession, Bson filter, DeleteOptions options)
Removes at most one document from the collection that matches the given filter.org.reactivestreams.Publisher<DeleteResult>
deleteOne(Bson filter)
Removes at most one document from the collection that matches the given filter.org.reactivestreams.Publisher<DeleteResult>
deleteOne(Bson filter, DeleteOptions options)
Removes at most one document from the collection that matches the given filter.<TResult> DistinctPublisher<TResult>
distinct(ClientSession clientSession, String fieldName, Class<TResult> resultClass)
Gets the distinct values of the specified field name.<TResult> DistinctPublisher<TResult>
distinct(ClientSession clientSession, String fieldName, Bson filter, Class<TResult> resultClass)
Gets the distinct values of the specified field name.<TResult> DistinctPublisher<TResult>
distinct(String fieldName, Class<TResult> resultClass)
Gets the distinct values of the specified field name.<TResult> DistinctPublisher<TResult>
distinct(String fieldName, Bson filter, Class<TResult> resultClass)
Gets the distinct values of the specified field name.org.reactivestreams.Publisher<Void>
drop()
Drops this collection from the Database.org.reactivestreams.Publisher<Void>
drop(ClientSession clientSession)
Drops this collection from the Database.org.reactivestreams.Publisher<Void>
dropIndex(ClientSession clientSession, String indexName)
Drops the given index.org.reactivestreams.Publisher<Void>
dropIndex(ClientSession clientSession, String indexName, DropIndexOptions dropIndexOptions)
Drops the given index.org.reactivestreams.Publisher<Void>
dropIndex(ClientSession clientSession, Bson keys)
Drops the index given the keys used to create it.org.reactivestreams.Publisher<Void>
dropIndex(ClientSession clientSession, Bson keys, DropIndexOptions dropIndexOptions)
Drops the index given the keys used to create it.org.reactivestreams.Publisher<Void>
dropIndex(String indexName)
Drops the given index.org.reactivestreams.Publisher<Void>
dropIndex(String indexName, DropIndexOptions dropIndexOptions)
Drops the given index.org.reactivestreams.Publisher<Void>
dropIndex(Bson keys)
Drops the index given the keys used to create it.org.reactivestreams.Publisher<Void>
dropIndex(Bson keys, DropIndexOptions dropIndexOptions)
Drops the index given the keys used to create it.org.reactivestreams.Publisher<Void>
dropIndexes()
Drop all the indexes on this collection, except for the default on _id.org.reactivestreams.Publisher<Void>
dropIndexes(DropIndexOptions dropIndexOptions)
Drop all the indexes on this collection, except for the default on _id.org.reactivestreams.Publisher<Void>
dropIndexes(ClientSession clientSession)
Drop all the indexes on this collection, except for the default on _id.org.reactivestreams.Publisher<Void>
dropIndexes(ClientSession clientSession, DropIndexOptions dropIndexOptions)
Drop all the indexes on this collection, except for the default on _id.org.reactivestreams.Publisher<Long>
estimatedDocumentCount()
Gets an estimate of the count of documents in a collection using collection metadata.org.reactivestreams.Publisher<Long>
estimatedDocumentCount(EstimatedDocumentCountOptions options)
Gets an estimate of the count of documents in a collection using collection metadata.FindPublisher<TDocument>
find()
Finds all documents in the collection.FindPublisher<TDocument>
find(ClientSession clientSession)
Finds all documents in the collection.<TResult> FindPublisher<TResult>
find(ClientSession clientSession, Class<TResult> clazz)
Finds all documents in the collection.FindPublisher<TDocument>
find(ClientSession clientSession, Bson filter)
Finds all documents in the collection.<TResult> FindPublisher<TResult>
find(ClientSession clientSession, Bson filter, Class<TResult> clazz)
Finds all documents in the collection.<TResult> FindPublisher<TResult>
find(Class<TResult> clazz)
Finds all documents in the collection.FindPublisher<TDocument>
find(Bson filter)
Finds all documents in the collection.<TResult> FindPublisher<TResult>
find(Bson filter, Class<TResult> clazz)
Finds all documents in the collection.org.reactivestreams.Publisher<TDocument>
findOneAndDelete(ClientSession clientSession, Bson filter)
Atomically find a document and remove it.org.reactivestreams.Publisher<TDocument>
findOneAndDelete(ClientSession clientSession, Bson filter, FindOneAndDeleteOptions options)
Atomically find a document and remove it.org.reactivestreams.Publisher<TDocument>
findOneAndDelete(Bson filter)
Atomically find a document and remove it.org.reactivestreams.Publisher<TDocument>
findOneAndDelete(Bson filter, FindOneAndDeleteOptions options)
Atomically find a document and remove it.org.reactivestreams.Publisher<TDocument>
findOneAndReplace(ClientSession clientSession, Bson filter, TDocument replacement)
Atomically find a document and replace it.org.reactivestreams.Publisher<TDocument>
findOneAndReplace(ClientSession clientSession, Bson filter, TDocument replacement, FindOneAndReplaceOptions options)
Atomically find a document and replace it.org.reactivestreams.Publisher<TDocument>
findOneAndReplace(Bson filter, TDocument replacement)
Atomically find a document and replace it.org.reactivestreams.Publisher<TDocument>
findOneAndReplace(Bson filter, TDocument replacement, FindOneAndReplaceOptions options)
Atomically find a document and replace it.org.reactivestreams.Publisher<TDocument>
findOneAndUpdate(ClientSession clientSession, Bson filter, List<? extends Bson> update)
Atomically find a document and update it.org.reactivestreams.Publisher<TDocument>
findOneAndUpdate(ClientSession clientSession, Bson filter, List<? extends Bson> update, FindOneAndUpdateOptions options)
Atomically find a document and update it.org.reactivestreams.Publisher<TDocument>
findOneAndUpdate(ClientSession clientSession, Bson filter, Bson update)
Atomically find a document and update it.org.reactivestreams.Publisher<TDocument>
findOneAndUpdate(ClientSession clientSession, Bson filter, Bson update, FindOneAndUpdateOptions options)
Atomically find a document and update it.org.reactivestreams.Publisher<TDocument>
findOneAndUpdate(Bson filter, List<? extends Bson> update)
Atomically find a document and update it.org.reactivestreams.Publisher<TDocument>
findOneAndUpdate(Bson filter, List<? extends Bson> update, FindOneAndUpdateOptions options)
Atomically find a document and update it.org.reactivestreams.Publisher<TDocument>
findOneAndUpdate(Bson filter, Bson update)
Atomically find a document and update it.org.reactivestreams.Publisher<TDocument>
findOneAndUpdate(Bson filter, Bson update, FindOneAndUpdateOptions options)
Atomically find a document and update it.CodecRegistry
getCodecRegistry()
Get the codec registry for the MongoCollection.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.org.reactivestreams.Publisher<InsertManyResult>
insertMany(ClientSession clientSession, List<? extends TDocument> documents)
Inserts a batch of documents.org.reactivestreams.Publisher<InsertManyResult>
insertMany(ClientSession clientSession, List<? extends TDocument> documents, InsertManyOptions options)
Inserts a batch of documents.org.reactivestreams.Publisher<InsertManyResult>
insertMany(List<? extends TDocument> documents)
Inserts a batch of documents.org.reactivestreams.Publisher<InsertManyResult>
insertMany(List<? extends TDocument> documents, InsertManyOptions options)
Inserts a batch of documents.org.reactivestreams.Publisher<InsertOneResult>
insertOne(ClientSession clientSession, TDocument document)
Inserts the provided document.org.reactivestreams.Publisher<InsertOneResult>
insertOne(ClientSession clientSession, TDocument document, InsertOneOptions options)
Inserts the provided document.org.reactivestreams.Publisher<InsertOneResult>
insertOne(TDocument document)
Inserts the provided document.org.reactivestreams.Publisher<InsertOneResult>
insertOne(TDocument document, InsertOneOptions options)
Inserts the provided document.ListIndexesPublisher<Document>
listIndexes()
Get all the indexes in this collection.ListIndexesPublisher<Document>
listIndexes(ClientSession clientSession)
Get all the indexes in this collection.<TResult> ListIndexesPublisher<TResult>
listIndexes(ClientSession clientSession, Class<TResult> clazz)
Get all the indexes in this collection.<TResult> ListIndexesPublisher<TResult>
listIndexes(Class<TResult> clazz)
Get all the indexes in this collection.MapReducePublisher<TDocument>
mapReduce(ClientSession clientSession, String mapFunction, String reduceFunction)
Aggregates documents according to the specified map-reduce function.<TResult> MapReducePublisher<TResult>
mapReduce(ClientSession clientSession, String mapFunction, String reduceFunction, Class<TResult> clazz)
Aggregates documents according to the specified map-reduce function.MapReducePublisher<TDocument>
mapReduce(String mapFunction, String reduceFunction)
Aggregates documents according to the specified map-reduce function.<TResult> MapReducePublisher<TResult>
mapReduce(String mapFunction, String reduceFunction, Class<TResult> clazz)
Aggregates documents according to the specified map-reduce function.org.reactivestreams.Publisher<Void>
renameCollection(MongoNamespace newCollectionNamespace)
Rename the collection with oldCollectionName to the newCollectionName.org.reactivestreams.Publisher<Void>
renameCollection(MongoNamespace newCollectionNamespace, RenameCollectionOptions options)
Rename the collection with oldCollectionName to the newCollectionName.org.reactivestreams.Publisher<Void>
renameCollection(ClientSession clientSession, MongoNamespace newCollectionNamespace)
Rename the collection with oldCollectionName to the newCollectionName.org.reactivestreams.Publisher<Void>
renameCollection(ClientSession clientSession, MongoNamespace newCollectionNamespace, RenameCollectionOptions options)
Rename the collection with oldCollectionName to the newCollectionName.org.reactivestreams.Publisher<UpdateResult>
replaceOne(ClientSession clientSession, Bson filter, TDocument replacement)
Replace a document in the collection according to the specified arguments.org.reactivestreams.Publisher<UpdateResult>
replaceOne(ClientSession clientSession, Bson filter, TDocument replacement, ReplaceOptions options)
Replace a document in the collection according to the specified arguments.org.reactivestreams.Publisher<UpdateResult>
replaceOne(Bson filter, TDocument replacement)
Replace a document in the collection according to the specified arguments.org.reactivestreams.Publisher<UpdateResult>
replaceOne(Bson filter, TDocument replacement, ReplaceOptions options)
Replace a document in the collection according to the specified arguments.org.reactivestreams.Publisher<UpdateResult>
updateMany(ClientSession clientSession, Bson filter, List<? extends Bson> update)
Update all documents in the collection according to the specified arguments.org.reactivestreams.Publisher<UpdateResult>
updateMany(ClientSession clientSession, Bson filter, List<? extends Bson> update, UpdateOptions options)
Update all documents in the collection according to the specified arguments.org.reactivestreams.Publisher<UpdateResult>
updateMany(ClientSession clientSession, Bson filter, Bson update)
Update all documents in the collection according to the specified arguments.org.reactivestreams.Publisher<UpdateResult>
updateMany(ClientSession clientSession, Bson filter, Bson update, UpdateOptions options)
Update all documents in the collection according to the specified arguments.org.reactivestreams.Publisher<UpdateResult>
updateMany(Bson filter, List<? extends Bson> update)
Update all documents in the collection according to the specified arguments.org.reactivestreams.Publisher<UpdateResult>
updateMany(Bson filter, List<? extends Bson> update, UpdateOptions options)
Update all documents in the collection according to the specified arguments.org.reactivestreams.Publisher<UpdateResult>
updateMany(Bson filter, Bson update)
Update all documents in the collection according to the specified arguments.org.reactivestreams.Publisher<UpdateResult>
updateMany(Bson filter, Bson update, UpdateOptions options)
Update all documents in the collection according to the specified arguments.org.reactivestreams.Publisher<UpdateResult>
updateOne(ClientSession clientSession, Bson filter, List<? extends Bson> update)
Update a single document in the collection according to the specified arguments.org.reactivestreams.Publisher<UpdateResult>
updateOne(ClientSession clientSession, Bson filter, List<? extends Bson> update, UpdateOptions options)
Update a single document in the collection according to the specified arguments.org.reactivestreams.Publisher<UpdateResult>
updateOne(ClientSession clientSession, Bson filter, Bson update)
Update a single document in the collection according to the specified arguments.org.reactivestreams.Publisher<UpdateResult>
updateOne(ClientSession clientSession, Bson filter, Bson update, UpdateOptions options)
Update a single document in the collection according to the specified arguments.org.reactivestreams.Publisher<UpdateResult>
updateOne(Bson filter, List<? extends Bson> update)
Update a single document in the collection according to the specified arguments.org.reactivestreams.Publisher<UpdateResult>
updateOne(Bson filter, List<? extends Bson> update, UpdateOptions options)
Update a single document in the collection according to the specified arguments.org.reactivestreams.Publisher<UpdateResult>
updateOne(Bson filter, Bson update)
Update a single document in the collection according to the specified arguments.org.reactivestreams.Publisher<UpdateResult>
updateOne(Bson filter, Bson update, UpdateOptions options)
Update a single document in the collection according to the specified arguments.ChangeStreamPublisher<Document>
watch()
Creates a change stream for this collection.ChangeStreamPublisher<Document>
watch(ClientSession clientSession)
Creates a change stream for this collection.<TResult> ChangeStreamPublisher<TResult>
watch(ClientSession clientSession, Class<TResult> resultClass)
Creates a change stream for this collection.ChangeStreamPublisher<Document>
watch(ClientSession clientSession, List<? extends Bson> pipeline)
Creates a change stream for this collection.<TResult> ChangeStreamPublisher<TResult>
watch(ClientSession clientSession, List<? extends Bson> pipeline, Class<TResult> resultClass)
Creates a change stream for this collection.<TResult> ChangeStreamPublisher<TResult>
watch(Class<TResult> resultClass)
Creates a change stream for this collection.ChangeStreamPublisher<Document>
watch(List<? extends Bson> pipeline)
Creates a change stream for this collection.<TResult> ChangeStreamPublisher<TResult>
watch(List<? extends Bson> pipeline, 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>
MongoCollection<NewTDocument>withDocumentClass(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.
-
-
-
Method Detail
-
getNamespace
MongoNamespace getNamespace()
Gets the namespace of this collection.- Returns:
- the namespace
-
getDocumentClass
Class<TDocument> getDocumentClass()
Get the class of documents stored in this collection.- Returns:
- the class
-
getCodecRegistry
CodecRegistry getCodecRegistry()
Get the codec registry for the MongoCollection.- Returns:
- the
CodecRegistry
-
getReadPreference
ReadPreference getReadPreference()
Get the read preference for the MongoCollection.- Returns:
- the
ReadPreference
-
getWriteConcern
WriteConcern getWriteConcern()
Get the write concern for the MongoCollection.- Returns:
- the
WriteConcern
-
getReadConcern
ReadConcern getReadConcern()
Get the read concern for the MongoCollection.- Returns:
- the
ReadConcern
- Since:
- 1.2
- Since server release
- 3.2
-
withDocumentClass
<NewTDocument> MongoCollection<NewTDocument> withDocumentClass(Class<NewTDocument> clazz)
Create a new MongoCollection instance with a different default class to cast any documents returned from the database into..- Type Parameters:
NewTDocument
- The type that the new collection will encode documents from and decode documents to- Parameters:
clazz
- the default class to cast any documents returned from the database into.- Returns:
- a new MongoCollection instance with the different default class
-
withCodecRegistry
MongoCollection<TDocument> withCodecRegistry(CodecRegistry codecRegistry)
Create a new MongoCollection instance with a different codec registry.- Parameters:
codecRegistry
- the newCodecRegistry
for the collection- Returns:
- a new MongoCollection instance with the different codec registry
-
withReadPreference
MongoCollection<TDocument> withReadPreference(ReadPreference readPreference)
Create a new MongoCollection instance with a different read preference.- Parameters:
readPreference
- the newReadPreference
for the collection- Returns:
- a new MongoCollection instance with the different readPreference
-
withWriteConcern
MongoCollection<TDocument> withWriteConcern(WriteConcern writeConcern)
Create a new MongoCollection instance with a different write concern.- Parameters:
writeConcern
- the newWriteConcern
for the collection- Returns:
- a new MongoCollection instance with the different writeConcern
-
withReadConcern
MongoCollection<TDocument> withReadConcern(ReadConcern readConcern)
Create a new MongoCollection instance with a different read concern.- Parameters:
readConcern
- the newReadConcern
for the collection- Returns:
- a new MongoCollection instance with the different ReadConcern
- Since:
- 1.2
- Since server release
- 3.2
-
estimatedDocumentCount
org.reactivestreams.Publisher<Long> estimatedDocumentCount()
Gets an estimate of the count of documents in a collection using collection metadata.- Returns:
- a publisher with a single element indicating the estimated number of documents
- Since:
- 1.9
-
estimatedDocumentCount
org.reactivestreams.Publisher<Long> estimatedDocumentCount(EstimatedDocumentCountOptions options)
Gets an estimate of the count of documents in a collection using collection metadata.- Parameters:
options
- the options describing the count- Returns:
- a publisher with a single element indicating the estimated number of documents
- Since:
- 1.9
-
countDocuments
org.reactivestreams.Publisher<Long> countDocuments()
Counts the number of documents in the collection.Note: For a fast count of the total documents in a collection see
estimatedDocumentCount()
.
Note: When migrating fromcount()
tocountDocuments()
the following query operators must be replaced:+-------------+--------------------------------+ | Operator | Replacement | +=============+================================+ | $where | $expr | +-------------+--------------------------------+ | $near | $geoWithin with $center | +-------------+--------------------------------+ | $nearSphere | $geoWithin with $centerSphere | +-------------+--------------------------------+
- Returns:
- a publisher with a single element indicating the number of documents
- Since:
- 1.9
-
countDocuments
org.reactivestreams.Publisher<Long> countDocuments(Bson filter)
Counts the number of documents in the collection according to the given options.Note: For a fast count of the total documents in a collection see
estimatedDocumentCount()
.
Note: When migrating fromcount()
tocountDocuments()
the following query operators must be replaced:+-------------+--------------------------------+ | Operator | Replacement | +=============+================================+ | $where | $expr | +-------------+--------------------------------+ | $near | $geoWithin with $center | +-------------+--------------------------------+ | $nearSphere | $geoWithin with $centerSphere | +-------------+--------------------------------+
- Parameters:
filter
- the query filter- Returns:
- a publisher with a single element indicating the number of documents
- Since:
- 1.9
-
countDocuments
org.reactivestreams.Publisher<Long> countDocuments(Bson filter, CountOptions options)
Counts the number of documents in the collection according to the given options.Note: For a fast count of the total documents in a collection see
estimatedDocumentCount()
.
Note: When migrating fromcount()
tocountDocuments()
the following query operators must be replaced:+-------------+--------------------------------+ | Operator | Replacement | +=============+================================+ | $where | $expr | +-------------+--------------------------------+ | $near | $geoWithin with $center | +-------------+--------------------------------+ | $nearSphere | $geoWithin with $centerSphere | +-------------+--------------------------------+
- Parameters:
filter
- the query filteroptions
- the options describing the count- Returns:
- a publisher with a single element indicating the number of documents
- Since:
- 1.9
-
countDocuments
org.reactivestreams.Publisher<Long> countDocuments(ClientSession clientSession)
Counts the number of documents in the collection.Note: For a fast count of the total documents in a collection see
estimatedDocumentCount()
.
Note: When migrating fromcount()
tocountDocuments()
the following query operators must be replaced:+-------------+--------------------------------+ | Operator | Replacement | +=============+================================+ | $where | $expr | +-------------+--------------------------------+ | $near | $geoWithin with $center | +-------------+--------------------------------+ | $nearSphere | $geoWithin with $centerSphere | +-------------+--------------------------------+
- Parameters:
clientSession
- the client session with which to associate this operation- Returns:
- a publisher with a single element indicating the number of documents
- Since:
- 1.9
- Since server release
- 3.6
-
countDocuments
org.reactivestreams.Publisher<Long> countDocuments(ClientSession clientSession, Bson filter)
Counts the number of documents in the collection according to the given options.Note: For a fast count of the total documents in a collection see
estimatedDocumentCount()
.- Parameters:
clientSession
- the client session with which to associate this operationfilter
- the query filter- Returns:
- a publisher with a single element indicating the number of documents
- Since:
- 1.9
- Since server release
- 3.6
-
countDocuments
org.reactivestreams.Publisher<Long> countDocuments(ClientSession clientSession, Bson filter, CountOptions options)
Counts the number of documents in the collection according to the given options.Note: For a fast count of the total documents in a collection see
estimatedDocumentCount()
.
Note: When migrating fromcount()
tocountDocuments()
the following query operators must be replaced:+-------------+--------------------------------+ | Operator | Replacement | +=============+================================+ | $where | $expr | +-------------+--------------------------------+ | $near | $geoWithin with $center | +-------------+--------------------------------+ | $nearSphere | $geoWithin with $centerSphere | +-------------+--------------------------------+
- Parameters:
clientSession
- the client session with which to associate this operationfilter
- the query filteroptions
- the options describing the count- Returns:
- a publisher with a single element indicating the number of documents
- Since:
- 1.9
- Since server release
- 3.6
-
distinct
<TResult> DistinctPublisher<TResult> distinct(String fieldName, Class<TResult> resultClass)
Gets the distinct values of the specified field name.- Type Parameters:
TResult
- the target type of the iterable.- Parameters:
fieldName
- the field nameresultClass
- the default class to cast any distinct items into.- Returns:
- a publisher emitting the sequence of distinct values
- MongoDB documentation
- Distinct
-
distinct
<TResult> DistinctPublisher<TResult> distinct(String fieldName, Bson filter, Class<TResult> resultClass)
Gets the distinct values of the specified field name.- Type Parameters:
TResult
- the target type of the iterable.- Parameters:
fieldName
- the field namefilter
- the query filterresultClass
- the default class to cast any distinct items into.- Returns:
- an iterable of distinct values
- MongoDB documentation
- Distinct
-
distinct
<TResult> DistinctPublisher<TResult> distinct(ClientSession clientSession, String fieldName, Class<TResult> resultClass)
Gets the distinct values of the specified field name.- Type Parameters:
TResult
- the target type of the iterable.- Parameters:
clientSession
- the client session with which to associate this operationfieldName
- the field nameresultClass
- the default class to cast any distinct items into.- Returns:
- a publisher emitting the sequence of distinct values
- Since:
- 1.7
-
distinct
<TResult> DistinctPublisher<TResult> distinct(ClientSession clientSession, String fieldName, Bson filter, Class<TResult> resultClass)
Gets the distinct values of the specified field name.- Type Parameters:
TResult
- the target type of the iterable.- Parameters:
clientSession
- the client session with which to associate this operationfieldName
- the field namefilter
- the query filterresultClass
- the default class to cast any distinct items into.- Returns:
- an iterable of distinct values
- Since:
- 1.7
-
find
FindPublisher<TDocument> find()
Finds all documents in the collection.- Returns:
- the fluent find interface
- MongoDB documentation
- Find
-
find
<TResult> FindPublisher<TResult> find(Class<TResult> clazz)
Finds all documents in the collection.- Type Parameters:
TResult
- the target document type of the iterable.- Parameters:
clazz
- the class to decode each document into- Returns:
- the fluent find interface
- MongoDB documentation
- Find
-
find
FindPublisher<TDocument> find(Bson filter)
Finds all documents in the collection.- Parameters:
filter
- the query filter- Returns:
- the fluent find interface
- MongoDB documentation
- Find
-
find
<TResult> FindPublisher<TResult> find(Bson filter, Class<TResult> clazz)
Finds all documents in the collection.- Type Parameters:
TResult
- the target document type of the iterable.- Parameters:
filter
- the query filterclazz
- the class to decode each document into- Returns:
- the fluent find interface
- MongoDB documentation
- Find
-
find
FindPublisher<TDocument> find(ClientSession clientSession)
Finds all documents in the collection.
-
find
<TResult> FindPublisher<TResult> find(ClientSession clientSession, Class<TResult> clazz)
Finds all documents in the collection.
-
find
FindPublisher<TDocument> find(ClientSession clientSession, Bson filter)
Finds all documents in the collection.
-
find
<TResult> FindPublisher<TResult> find(ClientSession clientSession, Bson filter, Class<TResult> clazz)
Finds all documents in the collection.- Type Parameters:
TResult
- the target document type of the iterable.- Parameters:
clientSession
- the client session with which to associate this operationfilter
- the query filterclazz
- the class to decode each document into- Returns:
- the fluent find interface
- Since:
- 1.7
-
aggregate
AggregatePublisher<TDocument> aggregate(List<? extends Bson> pipeline)
Aggregates documents according to the specified aggregation pipeline.- Parameters:
pipeline
- the aggregate pipeline- Returns:
- a publisher containing the result of the aggregation operation
- MongoDB documentation
- Aggregation
-
aggregate
<TResult> AggregatePublisher<TResult> aggregate(List<? extends Bson> pipeline, Class<TResult> clazz)
Aggregates documents according to the specified aggregation pipeline.- Type Parameters:
TResult
- the target document type of the iterable.- Parameters:
pipeline
- the aggregate pipelineclazz
- the class to decode each document into- Returns:
- a publisher containing the result of the aggregation operation
- MongoDB documentation
- Aggregation
-
aggregate
AggregatePublisher<TDocument> aggregate(ClientSession clientSession, List<? extends Bson> pipeline)
Aggregates documents according to the specified aggregation pipeline.- Parameters:
clientSession
- the client session with which to associate this operationpipeline
- the aggregate pipeline- Returns:
- a publisher containing the result of the aggregation operation
- Since:
- 1.7
- MongoDB documentation
- Aggregation
- Since server release
- 3.6
-
aggregate
<TResult> AggregatePublisher<TResult> aggregate(ClientSession clientSession, List<? extends Bson> pipeline, Class<TResult> clazz)
Aggregates documents according to the specified aggregation pipeline.- Type Parameters:
TResult
- the target document type of the iterable.- Parameters:
clientSession
- the client session with which to associate this operationpipeline
- the aggregate pipelineclazz
- the class to decode each document into- Returns:
- a publisher containing the result of the aggregation operation
- Since:
- 1.7
- MongoDB documentation
- Aggregation
- Since server release
- 3.6
-
watch
ChangeStreamPublisher<Document> watch()
Creates a change stream for this collection.- Returns:
- the change stream iterable
- Since:
- 1.7
- MongoDB documentation
- $changeStream
- Since server release
- 3.6
-
watch
<TResult> ChangeStreamPublisher<TResult> watch(Class<TResult> resultClass)
Creates a change stream for this collection.- 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:
- 1.7
- MongoDB documentation
- $changeStream
- Since server release
- 3.6
-
watch
ChangeStreamPublisher<Document> watch(List<? extends Bson> pipeline)
Creates a change stream for this collection.- Parameters:
pipeline
- the aggregation pipeline to apply to the change stream- Returns:
- the change stream iterable
- Since:
- 1.6
- MongoDB documentation
- $changeStream
-
watch
<TResult> ChangeStreamPublisher<TResult> watch(List<? extends Bson> pipeline, Class<TResult> resultClass)
Creates a change stream for this collection.- 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:
- 1.6
- MongoDB documentation
- $changeStream
-
watch
ChangeStreamPublisher<Document> watch(ClientSession clientSession)
Creates a change stream for this collection.- Parameters:
clientSession
- the client session with which to associate this operation- Returns:
- the change stream iterable
- Since:
- 1.7
- MongoDB documentation
- $changeStream
- Since server release
- 3.6
-
watch
<TResult> ChangeStreamPublisher<TResult> watch(ClientSession clientSession, Class<TResult> resultClass)
Creates a change stream for this collection.- 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:
- 1.7
- MongoDB documentation
- $changeStream
- Since server release
- 3.6
-
watch
ChangeStreamPublisher<Document> watch(ClientSession clientSession, List<? extends Bson> pipeline)
Creates a change stream for this collection.- 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:
- 1.7
- MongoDB documentation
- $changeStream
- Since server release
- 3.6
-
watch
<TResult> ChangeStreamPublisher<TResult> watch(ClientSession clientSession, List<? extends Bson> pipeline, Class<TResult> resultClass)
Creates a change stream for this collection.- 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:
- 1.7
- MongoDB documentation
- $changeStream
- Since server release
- 3.6
-
mapReduce
MapReducePublisher<TDocument> mapReduce(String mapFunction, String reduceFunction)
Aggregates documents according to the specified map-reduce function.- Parameters:
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.- Returns:
- an publisher containing the result of the map-reduce operation
- MongoDB documentation
- map-reduce
-
mapReduce
<TResult> MapReducePublisher<TResult> mapReduce(String mapFunction, String reduceFunction, Class<TResult> clazz)
Aggregates documents according to the specified map-reduce function.- Type Parameters:
TResult
- the target document type of the iterable.- Parameters:
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.clazz
- the class to decode each resulting document into.- Returns:
- a publisher containing the result of the map-reduce operation
- MongoDB documentation
- map-reduce
-
mapReduce
MapReducePublisher<TDocument> mapReduce(ClientSession clientSession, String mapFunction, String reduceFunction)
Aggregates documents according to the specified map-reduce function.- Parameters:
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.- Returns:
- an publisher containing the result of the map-reduce operation
- Since:
- 1.7
- MongoDB documentation
- map-reduce
- Since server release
- 3.6
-
mapReduce
<TResult> MapReducePublisher<TResult> mapReduce(ClientSession clientSession, String mapFunction, String reduceFunction, Class<TResult> clazz)
Aggregates documents according to the specified map-reduce function.- Type Parameters:
TResult
- the target document type of the iterable.- Parameters:
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.clazz
- the class to decode each resulting document into.- Returns:
- a publisher containing the result of the map-reduce operation
- Since:
- 1.7
- MongoDB documentation
- map-reduce
- Since server release
- 3.6
-
bulkWrite
org.reactivestreams.Publisher<BulkWriteResult> bulkWrite(List<? extends WriteModel<? extends TDocument>> requests)
Executes a mix of inserts, updates, replaces, and deletes.- Parameters:
requests
- the writes to execute- Returns:
- a publisher with a single element the BulkWriteResult
-
bulkWrite
org.reactivestreams.Publisher<BulkWriteResult> bulkWrite(List<? extends WriteModel<? extends TDocument>> requests, BulkWriteOptions options)
Executes a mix of inserts, updates, replaces, and deletes.- Parameters:
requests
- the writes to executeoptions
- the options to apply to the bulk write operation- Returns:
- a publisher with a single element the BulkWriteResult
-
bulkWrite
org.reactivestreams.Publisher<BulkWriteResult> bulkWrite(ClientSession clientSession, List<? extends WriteModel<? extends TDocument>> requests)
Executes a mix of inserts, updates, replaces, and deletes.- Parameters:
clientSession
- the client session with which to associate this operationrequests
- the writes to execute- Returns:
- a publisher with a single element the BulkWriteResult
- Since:
- 1.7
- Since server release
- 3.6
-
bulkWrite
org.reactivestreams.Publisher<BulkWriteResult> bulkWrite(ClientSession clientSession, List<? extends WriteModel<? extends TDocument>> requests, BulkWriteOptions options)
Executes a mix of inserts, updates, replaces, and deletes.- Parameters:
clientSession
- the client session with which to associate this operationrequests
- the writes to executeoptions
- the options to apply to the bulk write operation- Returns:
- a publisher with a single element the BulkWriteResult
- Since:
- 1.7
- Since server release
- 3.6
-
insertOne
org.reactivestreams.Publisher<InsertOneResult> insertOne(TDocument document)
Inserts the provided document. If the document is missing an identifier, the driver should generate one.- Parameters:
document
- the document to insert- Returns:
- a publisher with a single element with the InsertOneResult or with either a com.mongodb.DuplicateKeyException or com.mongodb.MongoException
-
insertOne
org.reactivestreams.Publisher<InsertOneResult> insertOne(TDocument document, InsertOneOptions options)
Inserts the provided document. If the document is missing an identifier, the driver should generate one.- Parameters:
document
- the document to insertoptions
- the options to apply to the operation- Returns:
- a publisher with a single element with the InsertOneResult or with either a com.mongodb.DuplicateKeyException or com.mongodb.MongoException
- Since:
- 1.2
-
insertOne
org.reactivestreams.Publisher<InsertOneResult> insertOne(ClientSession clientSession, TDocument document)
Inserts the provided document. If the document is missing an identifier, the driver should generate one.- Parameters:
clientSession
- the client session with which to associate this operationdocument
- the document to insert- Returns:
- a publisher with a single element with the InsertOneResult or with either a com.mongodb.DuplicateKeyException or com.mongodb.MongoException
- Since:
- 1.7
- Since server release
- 3.6
-
insertOne
org.reactivestreams.Publisher<InsertOneResult> insertOne(ClientSession clientSession, TDocument document, InsertOneOptions options)
Inserts the provided document. If the document is missing an identifier, the driver should generate one.- Parameters:
clientSession
- the client session with which to associate this operationdocument
- the document to insertoptions
- the options to apply to the operation- Returns:
- a publisher with a single element with the InsertOneResult or with either a com.mongodb.DuplicateKeyException or com.mongodb.MongoException
- Since:
- 1.7
- Since server release
- 3.6
-
insertMany
org.reactivestreams.Publisher<InsertManyResult> insertMany(List<? extends TDocument> documents)
Inserts a batch of documents.- Parameters:
documents
- the documents to insert- Returns:
- a publisher with a single element with the InsertManyResult or with either a com.mongodb.DuplicateKeyException or com.mongodb.MongoException
-
insertMany
org.reactivestreams.Publisher<InsertManyResult> insertMany(List<? extends TDocument> documents, InsertManyOptions options)
Inserts a batch of documents.- Parameters:
documents
- the documents to insertoptions
- the options to apply to the operation- Returns:
- a publisher with a single element with the InsertManyResult or with either a com.mongodb.DuplicateKeyException or com.mongodb.MongoException
-
insertMany
org.reactivestreams.Publisher<InsertManyResult> insertMany(ClientSession clientSession, List<? extends TDocument> documents)
Inserts a batch of documents.- Parameters:
clientSession
- the client session with which to associate this operationdocuments
- the documents to insert- Returns:
- a publisher with a single element with the InsertManyResult or with either a com.mongodb.DuplicateKeyException or com.mongodb.MongoException
- Since:
- 1.7
- Since server release
- 3.6
-
insertMany
org.reactivestreams.Publisher<InsertManyResult> insertMany(ClientSession clientSession, List<? extends TDocument> documents, InsertManyOptions options)
Inserts a batch of documents.- Parameters:
clientSession
- the client session with which to associate this operationdocuments
- the documents to insertoptions
- the options to apply to the operation- Returns:
- a publisher with a single element with the InsertManyResult or with either a com.mongodb.DuplicateKeyException or com.mongodb.MongoException
- Since:
- 1.7
- Since server release
- 3.6
-
deleteOne
org.reactivestreams.Publisher<DeleteResult> deleteOne(Bson filter)
Removes at most one document from the collection that matches the given filter. If no documents match, the collection is not modified.- Parameters:
filter
- the query filter to apply the the delete operation- Returns:
- a publisher with a single element the DeleteResult or with an com.mongodb.MongoException
-
deleteOne
org.reactivestreams.Publisher<DeleteResult> deleteOne(Bson filter, DeleteOptions options)
Removes at most one document from the collection that matches the given filter. If no documents match, the collection is not modified.- Parameters:
filter
- the query filter to apply the the delete operationoptions
- the options to apply to the delete operation- Returns:
- a publisher with a single element the DeleteResult or with an com.mongodb.MongoException
- Since:
- 1.5
-
deleteOne
org.reactivestreams.Publisher<DeleteResult> deleteOne(ClientSession clientSession, Bson filter)
Removes at most one document from the collection that matches the given filter. If no documents match, the collection is not modified.- Parameters:
clientSession
- the client session with which to associate this operationfilter
- the query filter to apply the the delete operation- Returns:
- a publisher with a single element the DeleteResult or with an com.mongodb.MongoException
- Since:
- 1.7
- Since server release
- 3.6
-
deleteOne
org.reactivestreams.Publisher<DeleteResult> deleteOne(ClientSession clientSession, Bson filter, DeleteOptions options)
Removes at most one document from the collection that matches the given filter. If no documents match, the collection is not modified.- Parameters:
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 operation- Returns:
- a publisher with a single element the DeleteResult or with an com.mongodb.MongoException
- Since:
- 1.7
- Since server release
- 3.6
-
deleteMany
org.reactivestreams.Publisher<DeleteResult> deleteMany(Bson filter)
Removes all documents from the collection that match the given query filter. If no documents match, the collection is not modified.- Parameters:
filter
- the query filter to apply the the delete operation- Returns:
- a publisher with a single element the DeleteResult or with an com.mongodb.MongoException
-
deleteMany
org.reactivestreams.Publisher<DeleteResult> deleteMany(Bson filter, DeleteOptions options)
Removes all documents from the collection that match the given query filter. If no documents match, the collection is not modified.- Parameters:
filter
- the query filter to apply the the delete operationoptions
- the options to apply to the delete operation- Returns:
- a publisher with a single element the DeleteResult or with an com.mongodb.MongoException
- Since:
- 1.5
-
deleteMany
org.reactivestreams.Publisher<DeleteResult> deleteMany(ClientSession clientSession, Bson filter)
Removes all documents from the collection that match the given query filter. If no documents match, the collection is not modified.- Parameters:
clientSession
- the client session with which to associate this operationfilter
- the query filter to apply the the delete operation- Returns:
- a publisher with a single element the DeleteResult or with an com.mongodb.MongoException
- Since:
- 1.7
- Since server release
- 3.6
-
deleteMany
org.reactivestreams.Publisher<DeleteResult> deleteMany(ClientSession clientSession, Bson filter, DeleteOptions options)
Removes all documents from the collection that match the given query filter. If no documents match, the collection is not modified.- Parameters:
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 operation- Returns:
- a publisher with a single element the DeleteResult or with an com.mongodb.MongoException
- Since:
- 1.7
- Since server release
- 3.6
-
replaceOne
org.reactivestreams.Publisher<UpdateResult> replaceOne(Bson filter, TDocument replacement)
Replace a document in the collection according to the specified arguments.- Parameters:
filter
- the query filter to apply the the replace operationreplacement
- the replacement document- Returns:
- a publisher with a single element the UpdateResult
- MongoDB documentation
- Replace
-
replaceOne
org.reactivestreams.Publisher<UpdateResult> replaceOne(Bson filter, TDocument replacement, ReplaceOptions options)
Replace a document in the collection according to the specified arguments.- Parameters:
filter
- the query filter to apply the the replace operationreplacement
- the replacement documentoptions
- the options to apply to the replace operation- Returns:
- a publisher with a single element the UpdateResult
- Since:
- 1.8
- MongoDB documentation
- Replace
-
replaceOne
org.reactivestreams.Publisher<UpdateResult> replaceOne(ClientSession clientSession, Bson filter, TDocument replacement)
Replace a document in the collection according to the specified arguments.- Parameters:
clientSession
- the client session with which to associate this operationfilter
- the query filter to apply the the replace operationreplacement
- the replacement document- Returns:
- a publisher with a single element the UpdateResult
- Since:
- 1.7
-
replaceOne
org.reactivestreams.Publisher<UpdateResult> replaceOne(ClientSession clientSession, Bson filter, TDocument replacement, ReplaceOptions options)
Replace a document in the collection according to the specified arguments.- Parameters:
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 replace operation- Returns:
- a publisher with a single element the UpdateResult
- Since:
- 1.8
-
updateOne
org.reactivestreams.Publisher<UpdateResult> updateOne(Bson filter, Bson update)
Update a single document in the collection according to the specified arguments.- Parameters:
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.- Returns:
- a publisher with a single element the UpdateResult
- MongoDB documentation
- Updates
- Update Operators
-
updateOne
org.reactivestreams.Publisher<UpdateResult> updateOne(Bson filter, Bson update, UpdateOptions options)
Update a single document in the collection according to the specified arguments.- Parameters:
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 update operation- Returns:
- a publisher with a single element the UpdateResult
- MongoDB documentation
- Updates
- Update Operators
-
updateOne
org.reactivestreams.Publisher<UpdateResult> updateOne(ClientSession clientSession, Bson filter, Bson update)
Update a single document in the collection according to the specified arguments.- Parameters:
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.- Returns:
- a publisher with a single element the UpdateResult
- Since:
- 1.7
- MongoDB documentation
- Updates
- Update Operators
- Since server release
- 3.6
-
updateOne
org.reactivestreams.Publisher<UpdateResult> updateOne(ClientSession clientSession, Bson filter, Bson update, UpdateOptions options)
Update a single document in the collection according to the specified arguments.- Parameters:
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 update operation- Returns:
- a publisher with a single element the UpdateResult
- Since:
- 1.7
- MongoDB documentation
- Updates
- Update Operators
- Since server release
- 3.6
-
updateOne
org.reactivestreams.Publisher<UpdateResult> updateOne(Bson filter, List<? extends Bson> update)
Update a single document in the collection according to the specified arguments.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
- Parameters:
filter
- a document describing the query filter, which may not be null.update
- a pipeline describing the update, which may not be null.- Returns:
- a publisher with a single element the UpdateResult
- Since:
- 1.12
- MongoDB documentation
- Updates
- Update Operators
- Since server release
- 4.2
-
updateOne
org.reactivestreams.Publisher<UpdateResult> updateOne(Bson filter, List<? extends Bson> update, UpdateOptions options)
Update a single document in the collection according to the specified arguments.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
- Parameters:
filter
- a document describing the query filter, which may not be null.update
- a pipeline describing the update, which may not be null.options
- the options to apply to the update operation- Returns:
- a publisher with a single element the UpdateResult
- Since:
- 1.12
- MongoDB documentation
- Updates
- Update Operators
- Since server release
- 4.2
-
updateOne
org.reactivestreams.Publisher<UpdateResult> updateOne(ClientSession clientSession, Bson filter, List<? extends Bson> update)
Update a single document in the collection according to the specified arguments.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
- Parameters:
clientSession
- the client session with which to associate this operationfilter
- a document describing the query filter, which may not be null.update
- a pipeline describing the update, which may not be null.- Returns:
- a publisher with a single element the UpdateResult
- Since:
- 1.12
- MongoDB documentation
- Updates
- Update Operators
- Since server release
- 4.2
-
updateOne
org.reactivestreams.Publisher<UpdateResult> updateOne(ClientSession clientSession, Bson filter, List<? extends Bson> update, UpdateOptions options)
Update a single document in the collection according to the specified arguments.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
- Parameters:
clientSession
- the client session with which to associate this operationfilter
- a document describing the query filter, which may not be null.update
- a pipeline describing the update, which may not be null.options
- the options to apply to the update operation- Returns:
- a publisher with a single element the UpdateResult
- Since:
- 1.12
- MongoDB documentation
- Updates
- Update Operators
- Since server release
- 4.2
-
updateMany
org.reactivestreams.Publisher<UpdateResult> updateMany(Bson filter, Bson update)
Update all documents in the collection according to the specified arguments.- Parameters:
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.- Returns:
- a publisher with a single element the UpdateResult
- MongoDB documentation
- Updates
- Update Operators
-
updateMany
org.reactivestreams.Publisher<UpdateResult> updateMany(Bson filter, Bson update, UpdateOptions options)
Update all documents in the collection according to the specified arguments.- Parameters:
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 update operation- Returns:
- a publisher with a single element the UpdateResult
- MongoDB documentation
- Updates
- Update Operators
-
updateMany
org.reactivestreams.Publisher<UpdateResult> updateMany(ClientSession clientSession, Bson filter, Bson update)
Update all documents in the collection according to the specified arguments.- Parameters:
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.- Returns:
- a publisher with a single element the UpdateResult
- Since:
- 1.7
- MongoDB documentation
- Updates
- Update Operators
- Since server release
- 3.6
-
updateMany
org.reactivestreams.Publisher<UpdateResult> updateMany(ClientSession clientSession, Bson filter, Bson update, UpdateOptions options)
Update all documents in the collection according to the specified arguments.- Parameters:
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 update operation- Returns:
- a publisher with a single element the UpdateResult
- Since:
- 1.7
- MongoDB documentation
- Updates
- Update Operators
- Since server release
- 3.6
-
updateMany
org.reactivestreams.Publisher<UpdateResult> updateMany(Bson filter, List<? extends Bson> update)
Update all documents in the collection according to the specified arguments.- Parameters:
filter
- a document describing the query filter, which may not be null.update
- a pipeline describing the update, which may not be null.- Returns:
- a publisher with a single element the UpdateResult
- Since:
- 1.12
- MongoDB documentation
- Updates
- Update Operators
- Since server release
- 4.2
-
updateMany
org.reactivestreams.Publisher<UpdateResult> updateMany(Bson filter, List<? extends Bson> update, UpdateOptions options)
Update all documents in the collection according to the specified arguments.- Parameters:
filter
- a document describing the query filter, which may not be null.update
- a pipeline describing the update, which may not be null.options
- the options to apply to the update operation- Returns:
- a publisher with a single element the UpdateResult
- Since:
- 1.12
- MongoDB documentation
- Updates
- Update Operators
- Since server release
- 4.2
-
updateMany
org.reactivestreams.Publisher<UpdateResult> updateMany(ClientSession clientSession, Bson filter, List<? extends Bson> update)
Update all documents in the collection according to the specified arguments.- Parameters:
clientSession
- the client session with which to associate this operationfilter
- a document describing the query filter, which may not be null.update
- a pipeline describing the update, which may not be null.- Returns:
- a publisher with a single element the UpdateResult
- Since:
- 1.12
- MongoDB documentation
- Updates
- Update Operators
- Since server release
- 4.2
-
updateMany
org.reactivestreams.Publisher<UpdateResult> updateMany(ClientSession clientSession, Bson filter, List<? extends Bson> update, UpdateOptions options)
Update all documents in the collection according to the specified arguments.- Parameters:
clientSession
- the client session with which to associate this operationfilter
- a document describing the query filter, which may not be null.update
- a pipeline describing the update, which may not be null.options
- the options to apply to the update operation- Returns:
- a publisher with a single element the UpdateResult
- Since:
- 1.12
- MongoDB documentation
- Updates
- Update Operators
- Since server release
- 4.2
-
findOneAndDelete
org.reactivestreams.Publisher<TDocument> findOneAndDelete(Bson filter)
Atomically find a document and remove it.- Parameters:
filter
- the query filter to find the document with- Returns:
- a publisher with a single element the document that was removed. If no documents matched the query filter, then null will be returned
-
findOneAndDelete
org.reactivestreams.Publisher<TDocument> findOneAndDelete(Bson filter, FindOneAndDeleteOptions options)
Atomically find a document and remove it.- Parameters:
filter
- the query filter to find the document withoptions
- the options to apply to the operation- Returns:
- a publisher with a single element the document that was removed. If no documents matched the query filter, then null will be returned
-
findOneAndDelete
org.reactivestreams.Publisher<TDocument> findOneAndDelete(ClientSession clientSession, Bson filter)
Atomically find a document and remove it.- Parameters:
clientSession
- the client session with which to associate this operationfilter
- the query filter to find the document with- Returns:
- a publisher with a single element the document that was removed. If no documents matched the query filter, then null will be returned
- Since:
- 1.7
- Since server release
- 3.6
-
findOneAndDelete
org.reactivestreams.Publisher<TDocument> findOneAndDelete(ClientSession clientSession, Bson filter, FindOneAndDeleteOptions options)
Atomically find a document and remove it.- Parameters:
clientSession
- the client session with which to associate this operationfilter
- the query filter to find the document withoptions
- the options to apply to the operation- Returns:
- a publisher with a single element the document that was removed. If no documents matched the query filter, then null will be returned
- Since:
- 1.7
- Since server release
- 3.6
-
findOneAndReplace
org.reactivestreams.Publisher<TDocument> findOneAndReplace(Bson filter, TDocument replacement)
Atomically find a document and replace it.- Parameters:
filter
- the query filter to apply the the replace operationreplacement
- the replacement document- Returns:
- a publisher with a single element the document that was replaced. Depending on the value of the
returnOriginal
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 returned
-
findOneAndReplace
org.reactivestreams.Publisher<TDocument> findOneAndReplace(Bson filter, TDocument replacement, FindOneAndReplaceOptions options)
Atomically find a document and replace it.- Parameters:
filter
- the query filter to apply the the replace operationreplacement
- the replacement documentoptions
- the options to apply to the operation- Returns:
- a publisher with a single element the document that was replaced. Depending on the value of the
returnOriginal
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 returned
-
findOneAndReplace
org.reactivestreams.Publisher<TDocument> findOneAndReplace(ClientSession clientSession, Bson filter, TDocument replacement)
Atomically find a document and replace it.- Parameters:
clientSession
- the client session with which to associate this operationfilter
- the query filter to apply the the replace operationreplacement
- the replacement document- Returns:
- a publisher with a single element the document that was replaced. Depending on the value of the
returnOriginal
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 returned - Since:
- 1.7
- Since server release
- 3.6
-
findOneAndReplace
org.reactivestreams.Publisher<TDocument> findOneAndReplace(ClientSession clientSession, Bson filter, TDocument replacement, FindOneAndReplaceOptions options)
Atomically find a document and replace it.- Parameters:
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 operation- Returns:
- a publisher with a single element the document that was replaced. Depending on the value of the
returnOriginal
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 returned - Since:
- 1.7
- Since server release
- 3.6
-
findOneAndUpdate
org.reactivestreams.Publisher<TDocument> findOneAndUpdate(Bson filter, Bson update)
Atomically find a document and update it.- Parameters:
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.- Returns:
- a publisher with a single element the document that was updated before the update was applied. If no documents matched the query filter, then null will be returned
-
findOneAndUpdate
org.reactivestreams.Publisher<TDocument> findOneAndUpdate(Bson filter, Bson update, FindOneAndUpdateOptions options)
Atomically find a document and update it.- Parameters:
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 operation- Returns:
- a publisher with a single element the document that was updated. Depending on the value of the
returnOriginal
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 returned
-
findOneAndUpdate
org.reactivestreams.Publisher<TDocument> findOneAndUpdate(ClientSession clientSession, Bson filter, Bson update)
Atomically find a document and update it.- Parameters:
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.- Returns:
- a publisher with a single element the document that was updated before the update was applied. If no documents matched the query filter, then null will be returned
- Since:
- 1.7
- Since server release
- 3.6
-
findOneAndUpdate
org.reactivestreams.Publisher<TDocument> findOneAndUpdate(ClientSession clientSession, Bson filter, Bson update, FindOneAndUpdateOptions options)
Atomically find a document and update it.- Parameters:
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 operation- Returns:
- a publisher with a single element the document that was updated. Depending on the value of the
returnOriginal
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 returned - Since:
- 1.7
- Since server release
- 3.6
-
findOneAndUpdate
org.reactivestreams.Publisher<TDocument> findOneAndUpdate(Bson filter, List<? extends Bson> update)
Atomically find a document and update it.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
- Parameters:
filter
- a document describing the query filter, which may not be null.update
- a pipeline describing the update, which may not be null.- Returns:
- a publisher with a single element the document that was updated. Depending on the value of the
returnOriginal
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 returned - Since:
- 1.12
- Since server release
- 4.2
-
findOneAndUpdate
org.reactivestreams.Publisher<TDocument> findOneAndUpdate(Bson filter, List<? extends Bson> update, FindOneAndUpdateOptions options)
Atomically find a document and update it.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
- Parameters:
filter
- a document describing the query filter, which may not be null.update
- a pipeline describing the update, which may not be null.options
- the options to apply to the operation- Returns:
- a publisher with a single element the document that was updated. Depending on the value of the
returnOriginal
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 returned - Since:
- 1.12
- Since server release
- 4.2
-
findOneAndUpdate
org.reactivestreams.Publisher<TDocument> findOneAndUpdate(ClientSession clientSession, Bson filter, List<? extends Bson> update)
Atomically find a document and update it.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
- Parameters:
clientSession
- the client session with which to associate this operationfilter
- a document describing the query filter, which may not be null.update
- a pipeline describing the update, which may not be null.- Returns:
- a publisher with a single element the document that was updated. Depending on the value of the
returnOriginal
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 returned - Since:
- 1.12
- Since server release
- 4.2
-
findOneAndUpdate
org.reactivestreams.Publisher<TDocument> findOneAndUpdate(ClientSession clientSession, Bson filter, List<? extends Bson> update, FindOneAndUpdateOptions options)
Atomically find a document and update it.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
- Parameters:
clientSession
- the client session with which to associate this operationfilter
- a document describing the query filter, which may not be null.update
- a pipeline describing the update, which may not be null.options
- the options to apply to the operation- Returns:
- a publisher with a single element the document that was updated. Depending on the value of the
returnOriginal
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 returned - Since:
- 1.12
- Since server release
- 4.2
-
drop
org.reactivestreams.Publisher<Void> drop()
Drops this collection from the Database.- Returns:
- an empty publisher that indicates when the operation has completed
- MongoDB documentation
- Drop Collection
-
drop
org.reactivestreams.Publisher<Void> drop(ClientSession clientSession)
Drops this collection from the Database.- Parameters:
clientSession
- the client session with which to associate this operation- Returns:
- an empty publisher that indicates when the operation has completed
- Since:
- 1.7
- MongoDB documentation
- Drop Collection
- Since server release
- 3.6
-
createIndex
org.reactivestreams.Publisher<String> createIndex(Bson key)
Creates an index.- Parameters:
key
- an object describing the index key(s), which may not be null.- Returns:
- an empty publisher that indicates when the operation has completed
- MongoDB documentation
- Ensure Index
-
createIndex
org.reactivestreams.Publisher<String> createIndex(Bson key, IndexOptions options)
Creates an index.- Parameters:
key
- an object describing the index key(s), which may not be null.options
- the options for the index- Returns:
- an empty publisher that indicates when the operation has completed
- MongoDB documentation
- Ensure Index
-
createIndex
org.reactivestreams.Publisher<String> createIndex(ClientSession clientSession, Bson key)
Creates an index.- Parameters:
clientSession
- the client session with which to associate this operationkey
- an object describing the index key(s), which may not be null.- Returns:
- an empty publisher that indicates when the operation has completed
- Since:
- 1.7
- MongoDB documentation
- Ensure Index
- Since server release
- 3.6
-
createIndex
org.reactivestreams.Publisher<String> createIndex(ClientSession clientSession, Bson key, IndexOptions options)
Creates an index.- Parameters:
clientSession
- the client session with which to associate this operationkey
- an object describing the index key(s), which may not be null.options
- the options for the index- Returns:
- an empty publisher that indicates when the operation has completed
- Since:
- 1.7
- MongoDB documentation
- Ensure Index
- Since server release
- 3.6
-
createIndexes
org.reactivestreams.Publisher<String> createIndexes(List<IndexModel> indexes)
Create multiple indexes.- Parameters:
indexes
- the list of indexes- Returns:
- an empty publisher that indicates when the operation has completed
- MongoDB documentation
- Create indexes
-
createIndexes
org.reactivestreams.Publisher<String> createIndexes(List<IndexModel> indexes, CreateIndexOptions createIndexOptions)
Create multiple indexes.- Parameters:
indexes
- the list of indexescreateIndexOptions
- options to use when creating indexes- Returns:
- an empty publisher that indicates when the operation has completed
- Since:
- 1.7
- MongoDB documentation
- Create indexes
-
createIndexes
org.reactivestreams.Publisher<String> createIndexes(ClientSession clientSession, List<IndexModel> indexes)
Create multiple indexes.- Parameters:
clientSession
- the client session with which to associate this operationindexes
- the list of indexes- Returns:
- an empty publisher that indicates when the operation has completed
- Since:
- 1.7
- MongoDB documentation
- Create indexes
- Since server release
- 3.6
-
createIndexes
org.reactivestreams.Publisher<String> createIndexes(ClientSession clientSession, List<IndexModel> indexes, CreateIndexOptions createIndexOptions)
Create multiple indexes.- Parameters:
clientSession
- the client session with which to associate this operationindexes
- the list of indexescreateIndexOptions
- options to use when creating indexes- Returns:
- an empty publisher that indicates when the operation has completed
- Since:
- 1.7
- MongoDB documentation
- Create indexes
- Since server release
- 3.6
-
listIndexes
ListIndexesPublisher<Document> listIndexes()
Get all the indexes in this collection.- Returns:
- the fluent list indexes interface
- MongoDB documentation
- listIndexes
-
listIndexes
<TResult> ListIndexesPublisher<TResult> listIndexes(Class<TResult> clazz)
Get all the indexes in this collection.- Type Parameters:
TResult
- the target document type of the iterable.- Parameters:
clazz
- the class to decode each document into- Returns:
- the fluent list indexes interface
- MongoDB documentation
- listIndexes
-
listIndexes
ListIndexesPublisher<Document> listIndexes(ClientSession clientSession)
Get all the indexes in this collection.- Parameters:
clientSession
- the client session with which to associate this operation- Returns:
- the fluent list indexes interface
- Since:
- 1.7
- MongoDB documentation
- listIndexes
- Since server release
- 3.6
-
listIndexes
<TResult> ListIndexesPublisher<TResult> listIndexes(ClientSession clientSession, Class<TResult> clazz)
Get all the indexes in this collection.- Type Parameters:
TResult
- the target document type of the iterable.- Parameters:
clientSession
- the client session with which to associate this operationclazz
- the class to decode each document into- Returns:
- the fluent list indexes interface
- Since:
- 1.7
- MongoDB documentation
- listIndexes
- Since server release
- 3.6
-
dropIndex
org.reactivestreams.Publisher<Void> dropIndex(String indexName)
Drops the given index.- Parameters:
indexName
- the name of the index to remove- Returns:
- an empty publisher that indicates when the operation has completed
- MongoDB documentation
- Drop Indexes
-
dropIndex
org.reactivestreams.Publisher<Void> dropIndex(Bson keys)
Drops the index given the keys used to create it.- Parameters:
keys
- the keys of the index to remove- Returns:
- an empty publisher that indicates when the operation has completed
- MongoDB documentation
- Drop indexes
-
dropIndex
org.reactivestreams.Publisher<Void> dropIndex(String indexName, DropIndexOptions dropIndexOptions)
Drops the given index.- Parameters:
indexName
- the name of the index to removedropIndexOptions
- options to use when dropping indexes- Returns:
- an empty publisher that indicates when the operation has completed
- Since:
- 1.7
- MongoDB documentation
- Drop Indexes
-
dropIndex
org.reactivestreams.Publisher<Void> dropIndex(Bson keys, DropIndexOptions dropIndexOptions)
Drops the index given the keys used to create it.- Parameters:
keys
- the keys of the index to removedropIndexOptions
- options to use when dropping indexes- Returns:
- an empty publisher that indicates when the operation has completed
- Since:
- 1.7
- MongoDB documentation
- Drop indexes
-
dropIndex
org.reactivestreams.Publisher<Void> dropIndex(ClientSession clientSession, String indexName)
Drops the given index.- Parameters:
clientSession
- the client session with which to associate this operationindexName
- the name of the index to remove- Returns:
- an empty publisher that indicates when the operation has completed
- Since:
- 1.7
- MongoDB documentation
- Drop Indexes
- Since server release
- 3.6
-
dropIndex
org.reactivestreams.Publisher<Void> dropIndex(ClientSession clientSession, Bson keys)
Drops the index given the keys used to create it.- Parameters:
clientSession
- the client session with which to associate this operationkeys
- the keys of the index to remove- Returns:
- an empty publisher that indicates when the operation has completed
- Since:
- 1.7
- MongoDB documentation
- Drop indexes
- Since server release
- 3.6
-
dropIndex
org.reactivestreams.Publisher<Void> dropIndex(ClientSession clientSession, String indexName, DropIndexOptions dropIndexOptions)
Drops the given index.- Parameters:
clientSession
- the client session with which to associate this operationindexName
- the name of the index to removedropIndexOptions
- options to use when dropping indexes- Returns:
- an empty publisher that indicates when the operation has completed
- Since:
- 1.7
- MongoDB documentation
- Drop Indexes
- Since server release
- 3.6
-
dropIndex
org.reactivestreams.Publisher<Void> dropIndex(ClientSession clientSession, Bson keys, DropIndexOptions dropIndexOptions)
Drops the index given the keys used to create it.- Parameters:
clientSession
- the client session with which to associate this operationkeys
- the keys of the index to removedropIndexOptions
- options to use when dropping indexes- Returns:
- an empty publisher that indicates when the operation has completed
- Since:
- 1.7
- MongoDB documentation
- Drop indexes
- Since server release
- 3.6
-
dropIndexes
org.reactivestreams.Publisher<Void> dropIndexes()
Drop all the indexes on this collection, except for the default on _id.- Returns:
- an empty publisher that indicates when the operation has completed
- MongoDB documentation
- Drop Indexes
-
dropIndexes
org.reactivestreams.Publisher<Void> dropIndexes(DropIndexOptions dropIndexOptions)
Drop all the indexes on this collection, except for the default on _id.- Parameters:
dropIndexOptions
- options to use when dropping indexes- Returns:
- an empty publisher that indicates when the operation has completed
- Since:
- 1.7
- MongoDB documentation
- Drop Indexes
-
dropIndexes
org.reactivestreams.Publisher<Void> dropIndexes(ClientSession clientSession)
Drop all the indexes on this collection, except for the default on _id.- Parameters:
clientSession
- the client session with which to associate this operation- Returns:
- an empty publisher that indicates when the operation has completed
- Since:
- 1.7
- MongoDB documentation
- Drop Indexes
- Since server release
- 3.6
-
dropIndexes
org.reactivestreams.Publisher<Void> dropIndexes(ClientSession clientSession, DropIndexOptions dropIndexOptions)
Drop all the indexes on this collection, except for the default on _id.- Parameters:
clientSession
- the client session with which to associate this operationdropIndexOptions
- options to use when dropping indexes- Returns:
- an empty publisher that indicates when the operation has completed
- Since:
- 1.7
- MongoDB documentation
- Drop Indexes
- Since server release
- 3.6
-
renameCollection
org.reactivestreams.Publisher<Void> renameCollection(MongoNamespace newCollectionNamespace)
Rename the collection with oldCollectionName to the newCollectionName.- Parameters:
newCollectionNamespace
- the namespace the collection will be renamed to- Returns:
- an empty publisher that indicates when the operation has completed
- MongoDB documentation
- Rename collection
-
renameCollection
org.reactivestreams.Publisher<Void> renameCollection(MongoNamespace newCollectionNamespace, RenameCollectionOptions options)
Rename the collection with oldCollectionName to the newCollectionName.- Parameters:
newCollectionNamespace
- the name the collection will be renamed tooptions
- the options for renaming a collection- Returns:
- an empty publisher that indicates when the operation has completed
- MongoDB documentation
- Rename collection
-
renameCollection
org.reactivestreams.Publisher<Void> renameCollection(ClientSession clientSession, MongoNamespace newCollectionNamespace)
Rename the collection with oldCollectionName to the newCollectionName.- Parameters:
clientSession
- the client session with which to associate this operationnewCollectionNamespace
- the namespace the collection will be renamed to- Returns:
- an empty publisher that indicates when the operation has completed
- Since:
- 1.7
- MongoDB documentation
- Rename collection
- Since server release
- 3.6
-
renameCollection
org.reactivestreams.Publisher<Void> renameCollection(ClientSession clientSession, MongoNamespace newCollectionNamespace, RenameCollectionOptions options)
Rename the collection with oldCollectionName to the newCollectionName.- Parameters:
clientSession
- the client session with which to associate this operationnewCollectionNamespace
- the name the collection will be renamed tooptions
- the options for renaming a collection- Returns:
- an empty publisher that indicates when the operation has completed
- Since:
- 1.7
- MongoDB documentation
- Rename collection
- Since server release
- 3.6
-
-