Interface MongoCollection<TDocument>
- Type Parameters:
- TDocument- The type that this collection will encode documents from and decode documents to.
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.
 
- Since:
- 3.0
- 
Method SummaryModifier and TypeMethodDescriptionaggregate(ClientSession clientSession, List<? extends Bson> pipeline) Aggregates documents according to the specified aggregation pipeline.<TResult> AggregateIterable<TResult>aggregate(ClientSession clientSession, List<? extends Bson> pipeline, Class<TResult> resultClass) Aggregates documents according to the specified aggregation pipeline.Aggregates documents according to the specified aggregation pipeline.<TResult> AggregateIterable<TResult>Aggregates documents according to the specified aggregation pipeline.bulkWrite(ClientSession clientSession, List<? extends WriteModel<? extends TDocument>> requests) Executes a mix of inserts, updates, replaces, and deletes.bulkWrite(ClientSession clientSession, List<? extends WriteModel<? extends TDocument>> requests, BulkWriteOptions options) Executes a mix of inserts, updates, replaces, and deletes.bulkWrite(List<? extends WriteModel<? extends TDocument>> requests) Executes a mix of inserts, updates, replaces, and deletes.bulkWrite(List<? extends WriteModel<? extends TDocument>> requests, BulkWriteOptions options) Executes a mix of inserts, updates, replaces, and deletes.longCounts the number of documents in the collection.longcountDocuments(ClientSession clientSession) Counts the number of documents in the collection.longcountDocuments(ClientSession clientSession, Bson filter) Counts the number of documents in the collection according to the given options.longcountDocuments(ClientSession clientSession, Bson filter, CountOptions options) Counts the number of documents in the collection according to the given options.longcountDocuments(Bson filter) Counts the number of documents in the collection according to the given options.longcountDocuments(Bson filter, CountOptions options) Counts the number of documents in the collection according to the given options.createIndex(ClientSession clientSession, Bson keys) Create an index with the given keys.createIndex(ClientSession clientSession, Bson keys, IndexOptions indexOptions) Create an index with the given keys and options.createIndex(Bson keys) Create an index with the given keys.createIndex(Bson keys, IndexOptions indexOptions) Create an index with the given keys and options.createIndexes(ClientSession clientSession, List<IndexModel> indexes) Create multiple indexes.createIndexes(ClientSession clientSession, List<IndexModel> indexes, CreateIndexOptions createIndexOptions) Create multiple indexes.createIndexes(List<IndexModel> indexes) Create multiple indexes.createIndexes(List<IndexModel> indexes, CreateIndexOptions createIndexOptions) Create multiple indexes.createSearchIndex(String indexName, Bson definition) Create an Atlas Search index for the collection.createSearchIndex(Bson definition) Create an Atlas Search index with"default"name for the collection.createSearchIndexes(List<SearchIndexModel> searchIndexModels) Create one or more Atlas Search indexes for the collection.deleteMany(ClientSession clientSession, Bson filter) Removes all documents from the collection that match the given query filter.deleteMany(ClientSession clientSession, Bson filter, DeleteOptions options) Removes all documents from the collection that match the given query filter.deleteMany(Bson filter) Removes all documents from the collection that match the given query filter.deleteMany(Bson filter, DeleteOptions options) Removes all documents from the collection that match the given query filter.deleteOne(ClientSession clientSession, Bson filter) Removes at most one document from the collection that matches the given filter.deleteOne(ClientSession clientSession, Bson filter, DeleteOptions options) Removes at most one document from the collection that matches the given filter.Removes at most one document from the collection that matches the given filter.deleteOne(Bson filter, DeleteOptions options) Removes at most one document from the collection that matches the given filter.<TResult> DistinctIterable<TResult>distinct(ClientSession clientSession, String fieldName, Class<TResult> resultClass) Gets the distinct values of the specified field name.<TResult> DistinctIterable<TResult>distinct(ClientSession clientSession, String fieldName, Bson filter, Class<TResult> resultClass) Gets the distinct values of the specified field name.<TResult> DistinctIterable<TResult>Gets the distinct values of the specified field name.<TResult> DistinctIterable<TResult>Gets the distinct values of the specified field name.voiddrop()Drops this collection from the Database.voiddrop(ClientSession clientSession) Drops this collection from the Database.voiddrop(ClientSession clientSession, DropCollectionOptions dropCollectionOptions) Drops this collection from the Database.voiddrop(DropCollectionOptions dropCollectionOptions) Drops this collection from the Database.voiddropIndex(ClientSession clientSession, String indexName) Drops the index given its name.voiddropIndex(ClientSession clientSession, String indexName, DropIndexOptions dropIndexOptions) Drops the index given its name.voiddropIndex(ClientSession clientSession, Bson keys) Drops the index given the keys used to create it.voiddropIndex(ClientSession clientSession, Bson keys, DropIndexOptions dropIndexOptions) Drops the index given the keys used to create it.voidDrops the index given its name.voiddropIndex(String indexName, DropIndexOptions dropIndexOptions) Drops the index given its name.voidDrops the index given the keys used to create it.voiddropIndex(Bson keys, DropIndexOptions dropIndexOptions) Drops the index given the keys used to create it.voidDrop all the indexes on this collection, except for the default on _id.voiddropIndexes(ClientSession clientSession) Drop all the indexes on this collection, except for the default on _id.voiddropIndexes(ClientSession clientSession, DropIndexOptions dropIndexOptions) Drop all the indexes on this collection, except for the default on _id.voiddropIndexes(DropIndexOptions dropIndexOptions) Drop all the indexes on this collection, except for the default on _id.voiddropSearchIndex(String indexName) Drop an Atlas Search index given its name.longGets an estimate of the count of documents in a collection using collection metadata.longGets an estimate of the count of documents in a collection using collection metadata.find()Finds all documents in the collection.find(ClientSession clientSession) Finds all documents in the collection.<TResult> FindIterable<TResult>find(ClientSession clientSession, Class<TResult> resultClass) Finds all documents in the collection.find(ClientSession clientSession, Bson filter) Finds all documents in the collection.<TResult> FindIterable<TResult>find(ClientSession clientSession, Bson filter, Class<TResult> resultClass) Finds all documents in the collection.<TResult> FindIterable<TResult>Finds all documents in the collection.Finds all documents in the collection.<TResult> FindIterable<TResult>Finds all documents in the collection.findOneAndDelete(ClientSession clientSession, Bson filter) Atomically find a document and remove it.findOneAndDelete(ClientSession clientSession, Bson filter, FindOneAndDeleteOptions options) Atomically find a document and remove it.findOneAndDelete(Bson filter) Atomically find a document and remove it.findOneAndDelete(Bson filter, FindOneAndDeleteOptions options) Atomically find a document and remove it.findOneAndReplace(ClientSession clientSession, Bson filter, TDocument replacement) Atomically find a document and replace it.findOneAndReplace(ClientSession clientSession, Bson filter, TDocument replacement, FindOneAndReplaceOptions options) Atomically find a document and replace it.findOneAndReplace(Bson filter, TDocument replacement) Atomically find a document and replace it.findOneAndReplace(Bson filter, TDocument replacement, FindOneAndReplaceOptions options) Atomically find a document and replace it.findOneAndUpdate(ClientSession clientSession, Bson filter, List<? extends Bson> update) Atomically find a document and update it.findOneAndUpdate(ClientSession clientSession, Bson filter, List<? extends Bson> update, FindOneAndUpdateOptions options) Atomically find a document and update it.findOneAndUpdate(ClientSession clientSession, Bson filter, Bson update) Atomically find a document and update it.findOneAndUpdate(ClientSession clientSession, Bson filter, Bson update, FindOneAndUpdateOptions options) Atomically find a document and update it.findOneAndUpdate(Bson filter, List<? extends Bson> update) Atomically find a document and update it.findOneAndUpdate(Bson filter, List<? extends Bson> update, FindOneAndUpdateOptions options) Atomically find a document and update it.findOneAndUpdate(Bson filter, Bson update) Atomically find a document and update it.findOneAndUpdate(Bson filter, Bson update, FindOneAndUpdateOptions options) Atomically find a document and update it.Get the codec registry for the MongoCollection.Get the class of documents stored in this collection.Gets the namespace of this collection.Get the read concern for the MongoCollection.Get the read preference for the MongoCollection.Get the write concern for the MongoCollection.insertMany(ClientSession clientSession, List<? extends TDocument> documents) Inserts one or more documents.insertMany(ClientSession clientSession, List<? extends TDocument> documents, InsertManyOptions options) Inserts one or more documents.insertMany(List<? extends TDocument> documents) Inserts one or more documents.insertMany(List<? extends TDocument> documents, InsertManyOptions options) Inserts one or more documents.insertOne(ClientSession clientSession, TDocument document) Inserts the provided document.insertOne(ClientSession clientSession, TDocument document, InsertOneOptions options) Inserts the provided document.Inserts the provided document.insertOne(TDocument document, InsertOneOptions options) Inserts the provided document.Get all the indexes in this collection.listIndexes(ClientSession clientSession) Get all the indexes in this collection.<TResult> ListIndexesIterable<TResult>listIndexes(ClientSession clientSession, Class<TResult> resultClass) Get all the indexes in this collection.<TResult> ListIndexesIterable<TResult>listIndexes(Class<TResult> resultClass) Get all the indexes in this collection.Get all Atlas Search indexes in this collection.<TResult> ListSearchIndexesIterable<TResult>listSearchIndexes(Class<TResult> resultClass) Get all Atlas Search indexes in this collection.mapReduce(ClientSession clientSession, String mapFunction, String reduceFunction) Deprecated.Superseded by aggregate<TResult> MapReduceIterable<TResult>mapReduce(ClientSession clientSession, String mapFunction, String reduceFunction, Class<TResult> resultClass) Deprecated.Superseded by aggregateDeprecated.Superseded by aggregate<TResult> MapReduceIterable<TResult>Deprecated.Superseded by aggregatevoidrenameCollection(ClientSession clientSession, MongoNamespace newCollectionNamespace) Rename the collection with oldCollectionName to the newCollectionName.voidrenameCollection(ClientSession clientSession, MongoNamespace newCollectionNamespace, RenameCollectionOptions renameCollectionOptions) Rename the collection with oldCollectionName to the newCollectionName.voidrenameCollection(MongoNamespace newCollectionNamespace) Rename the collection with oldCollectionName to the newCollectionName.voidrenameCollection(MongoNamespace newCollectionNamespace, RenameCollectionOptions renameCollectionOptions) Rename the collection with oldCollectionName to the newCollectionName.replaceOne(ClientSession clientSession, Bson filter, TDocument replacement) Replace a document in the collection according to the specified arguments.replaceOne(ClientSession clientSession, Bson filter, TDocument replacement, ReplaceOptions replaceOptions) Replace a document in the collection according to the specified arguments.replaceOne(Bson filter, TDocument replacement) Replace a document in the collection according to the specified arguments.replaceOne(Bson filter, TDocument replacement, ReplaceOptions replaceOptions) Replace a document in the collection according to the specified arguments.updateMany(ClientSession clientSession, Bson filter, List<? extends Bson> update) Update all documents in the collection according to the specified arguments.updateMany(ClientSession clientSession, Bson filter, List<? extends Bson> update, UpdateOptions updateOptions) Update all documents in the collection according to the specified arguments.updateMany(ClientSession clientSession, Bson filter, Bson update) Update all documents in the collection according to the specified arguments.updateMany(ClientSession clientSession, Bson filter, Bson update, UpdateOptions updateOptions) Update all documents in the collection according to the specified arguments.updateMany(Bson filter, List<? extends Bson> update) Update all documents in the collection according to the specified arguments.updateMany(Bson filter, List<? extends Bson> update, UpdateOptions updateOptions) Update all documents in the collection according to the specified arguments.updateMany(Bson filter, Bson update) Update all documents in the collection according to the specified arguments.updateMany(Bson filter, Bson update, UpdateOptions updateOptions) Update all documents in the collection according to the specified arguments.updateOne(ClientSession clientSession, Bson filter, List<? extends Bson> update) Update a single document in the collection according to the specified arguments.updateOne(ClientSession clientSession, Bson filter, List<? extends Bson> update, UpdateOptions updateOptions) Update a single document in the collection according to the specified arguments.updateOne(ClientSession clientSession, Bson filter, Bson update) Update a single document in the collection according to the specified arguments.updateOne(ClientSession clientSession, Bson filter, Bson update, UpdateOptions updateOptions) Update a single document in the collection according to the specified arguments.Update a single document in the collection according to the specified arguments.updateOne(Bson filter, List<? extends Bson> update, UpdateOptions updateOptions) Update a single document in the collection according to the specified arguments.Update a single document in the collection according to the specified arguments.updateOne(Bson filter, Bson update, UpdateOptions updateOptions) Update a single document in the collection according to the specified arguments.voidupdateSearchIndex(String indexName, Bson definition) Update an Atlas Search index in the collection.watch()Creates a change stream for this collection.watch(ClientSession clientSession) Creates a change stream for this collection.<TResult> ChangeStreamIterable<TResult>watch(ClientSession clientSession, Class<TResult> resultClass) Creates a change stream for this collection.watch(ClientSession clientSession, List<? extends Bson> pipeline) Creates a change stream for this collection.<TResult> ChangeStreamIterable<TResult>watch(ClientSession clientSession, List<? extends Bson> pipeline, Class<TResult> resultClass) Creates a change stream for this collection.<TResult> ChangeStreamIterable<TResult>Creates a change stream for this collection.Creates a change stream for this collection.<TResult> ChangeStreamIterable<TResult>Creates a change stream for this collection.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..withReadConcern(ReadConcern readConcern) Create a new MongoCollection instance with a different read concern.withReadPreference(ReadPreference readPreference) Create a new MongoCollection instance with a different read preference.withWriteConcern(WriteConcern writeConcern) Create a new MongoCollection instance with a different write concern.
- 
Method Details- 
getNamespaceMongoNamespace getNamespace()Gets the namespace of this collection.- Returns:
- the namespace
 
- 
getDocumentClassGet the class of documents stored in this collection.- Returns:
- the class
 
- 
getCodecRegistryCodecRegistry getCodecRegistry()Get the codec registry for the MongoCollection.- Returns:
- the CodecRegistry
 
- 
getReadPreferenceReadPreference getReadPreference()Get the read preference for the MongoCollection.- Returns:
- the ReadPreference
 
- 
getWriteConcernWriteConcern getWriteConcern()Get the write concern for the MongoCollection.- Returns:
- the WriteConcern
 
- 
getReadConcernReadConcern getReadConcern()Get the read concern for the MongoCollection.- Returns:
- the ReadConcern
- Since:
- 3.2
- MongoDB documentation
- Read Concern
- Since server release
- 3.2
 
- 
withDocumentClassCreate 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
 
- 
withCodecRegistryCreate a new MongoCollection instance with a different codec registry.The CodecRegistryconfigured by this method is effectively treated by the driver as an instance ofCodecProvider, whichCodecRegistryextends. So there is no benefit to defining a class that implementsCodecRegistry. Rather, an application should always createCodecRegistryinstances using the factory methods inCodecRegistries.- Parameters:
- codecRegistry- the new- CodecRegistryfor the collection
- Returns:
- a new MongoCollection instance with the different codec registry
- See Also:
 
- 
withReadPreferenceCreate a new MongoCollection instance with a different read preference.- Parameters:
- readPreference- the new- ReadPreferencefor the collection
- Returns:
- a new MongoCollection instance with the different readPreference
 
- 
withWriteConcernCreate a new MongoCollection instance with a different write concern.- Parameters:
- writeConcern- the new- WriteConcernfor the collection
- Returns:
- a new MongoCollection instance with the different writeConcern
 
- 
withReadConcernCreate a new MongoCollection instance with a different read concern.- Parameters:
- readConcern- the new- ReadConcernfor the collection
- Returns:
- a new MongoCollection instance with the different ReadConcern
- Since:
- 3.2
- MongoDB documentation
- Read Concern
- Since server release
- 3.2
 
- 
countDocumentslong countDocuments()Counts the number of documents in the collection.Note: For a fast count of the total documents in a collection see estimatedDocumentCount(). When migrating fromcount()tocountDocuments()the following query operators must be replaced:+-------------+--------------------------------+ | Operator | Replacement | +=============+================================+ | $where | $expr | +-------------+--------------------------------+ | $near | $geoWithin with $center | +-------------+--------------------------------+ | $nearSphere | $geoWithin with $centerSphere | +-------------+--------------------------------+ - Returns:
- the number of documents in the collection
- Since:
- 3.8
 
- 
countDocumentsCounts 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(). 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:
- the number of documents in the collection
- Since:
- 3.8
 
- 
countDocumentsCounts 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(). 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
- options- the options describing the count
- Returns:
- the number of documents in the collection
- Since:
- 3.8
 
- 
countDocumentsCounts the number of documents in the collection.Note: For a fast count of the total documents in a collection see estimatedDocumentCount(). 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:
- the number of documents in the collection
- Since:
- 3.8
- Since server release
- 3.6
 
- 
countDocumentsCounts 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(). 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
- filter- the query filter
- Returns:
- the number of documents in the collection
- Since:
- 3.8
- Since server release
- 3.6
 
- 
countDocumentsCounts 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(). 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
- filter- the query filter
- options- the options describing the count
- Returns:
- the number of documents in the collection
- Since:
- 3.8
- Since server release
- 3.6
 
- 
estimatedDocumentCountlong estimatedDocumentCount()Gets an estimate of the count of documents in a collection using collection metadata.Implementation note: this method is implemented using the MongoDB server's count command - Returns:
- the number of documents in the collection
- Since:
- 3.8
- MongoDB documentation
- manual/reference/command/count/#behavior
 
- 
estimatedDocumentCountGets an estimate of the count of documents in a collection using collection metadata.Implementation note: this method is implemented using the MongoDB server's count command - Parameters:
- options- the options describing the count
- Returns:
- the number of documents in the collection
- Since:
- 3.8
- MongoDB documentation
- manual/reference/command/count/#behavior
 
- 
distinctGets the distinct values of the specified field name.- Type Parameters:
- TResult- the target type of the iterable.
- Parameters:
- fieldName- the field name
- resultClass- the class to cast any distinct items into.
- Returns:
- an iterable of distinct values
- MongoDB documentation
- Distinct
 
- 
distinct<TResult> DistinctIterable<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 name
- filter- the query filter
- resultClass- the class to cast any distinct items into.
- Returns:
- an iterable of distinct values
- MongoDB documentation
- Distinct
 
- 
distinct<TResult> DistinctIterable<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 operation
- fieldName- the field name
- resultClass- the class to cast any distinct items into.
- Returns:
- an iterable of distinct values
- Since:
- 3.6
 
- 
distinct<TResult> DistinctIterable<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 operation
- fieldName- the field name
- filter- the query filter
- resultClass- the class to cast any distinct items into.
- Returns:
- an iterable of distinct values
- Since:
- 3.6
 
- 
findFindIterable<TDocument> find()Finds all documents in the collection.- Returns:
- the find iterable interface
- MongoDB documentation
- Find
 
- 
findFinds all documents in the collection.- Type Parameters:
- TResult- the target document type of the iterable.
- Parameters:
- resultClass- the class to decode each document into
- Returns:
- the find iterable interface
- MongoDB documentation
- Find
 
- 
findFinds all documents in the collection.- Parameters:
- filter- the query filter
- Returns:
- the find iterable interface
- MongoDB documentation
- Find
 
- 
findFinds all documents in the collection.- Type Parameters:
- TResult- the target document type of the iterable.
- Parameters:
- filter- the query filter
- resultClass- the class to decode each document into
- Returns:
- the find iterable interface
- MongoDB documentation
- Find
 
- 
findFinds all documents in the collection.
- 
findFinds 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 operation
- resultClass- the class to decode each document into
- Returns:
- the find iterable interface
- Since:
- 3.6
 
- 
findFinds all documents in the collection.
- 
find<TResult> FindIterable<TResult> find(ClientSession clientSession, Bson filter, Class<TResult> resultClass) 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 operation
- filter- the query filter
- resultClass- the class to decode each document into
- Returns:
- the find iterable interface
- Since:
- 3.6
 
- 
aggregateAggregates documents according to the specified aggregation pipeline.- Parameters:
- pipeline- the aggregation pipeline
- Returns:
- an iterable containing the result of the aggregation operation
- MongoDB documentation
- Aggregation
- Since server release
- 2.2
 
- 
aggregate<TResult> AggregateIterable<TResult> aggregate(List<? extends Bson> pipeline, Class<TResult> resultClass) Aggregates documents according to the specified aggregation pipeline.- Type Parameters:
- TResult- the target document type of the iterable.
- Parameters:
- pipeline- the aggregation pipeline
- resultClass- the class to decode each document into
- Returns:
- an iterable containing the result of the aggregation operation
- MongoDB documentation
- Aggregation
- Since server release
- 2.2
 
- 
aggregateAggregates documents according to the specified aggregation pipeline.- Parameters:
- clientSession- the client session with which to associate this operation
- pipeline- the aggregation pipeline
- Returns:
- an iterable containing the result of the aggregation operation
- Since:
- 3.6
- MongoDB documentation
- Aggregation
- Since server release
- 3.6
 
- 
aggregate<TResult> AggregateIterable<TResult> aggregate(ClientSession clientSession, List<? extends Bson> pipeline, Class<TResult> resultClass) 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 operation
- pipeline- the aggregation pipeline
- resultClass- the class to decode each document into
- Returns:
- an iterable containing the result of the aggregation operation
- Since:
- 3.6
- MongoDB documentation
- Aggregation
- Since server release
- 3.6
 
- 
watchChangeStreamIterable<TDocument> watch()Creates a change stream for this collection.- Returns:
- the change stream iterable
- Since:
- 3.6
- MongoDB documentation
- Change Streams
 
- 
watchCreates 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:
- 3.6
- MongoDB documentation
- Change Streams
 
- 
watchCreates a change stream for this collection.- Parameters:
- pipeline- the aggregation pipeline to apply to the change stream.
- Returns:
- the change stream iterable
- Since:
- 3.6
- MongoDB documentation
- Change Streams
 
- 
watch<TResult> ChangeStreamIterable<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 stream
- resultClass- the class to decode each document into
- Returns:
- the change stream iterable
- Since:
- 3.6
- MongoDB documentation
- Change Streams
 
- 
watchCreates a change stream for this collection.- Parameters:
- clientSession- the client session with which to associate this operation
- Returns:
- the change stream iterable
- Since:
- 3.6
- MongoDB documentation
- Change Streams
- Since server release
- 3.6
 
- 
watch<TResult> ChangeStreamIterable<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 operation
- resultClass- the class to decode each document into
- Returns:
- the change stream iterable
- Since:
- 3.6
- MongoDB documentation
- Change Streams
- Since server release
- 3.6
 
- 
watchCreates a change stream for this collection.- Parameters:
- clientSession- the client session with which to associate this operation
- pipeline- the aggregation pipeline to apply to the change stream.
- Returns:
- the change stream iterable
- Since:
- 3.6
- MongoDB documentation
- Change Streams
- Since server release
- 3.6
 
- 
watch<TResult> ChangeStreamIterable<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 operation
- pipeline- the aggregation pipeline to apply to the change stream
- resultClass- the class to decode each document into
- Returns:
- the change stream iterable
- Since:
- 3.6
- MongoDB documentation
- Change Streams
- Since server release
- 3.6
 
- 
mapReduceDeprecated.Superseded by aggregateAggregates 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 iterable containing the result of the map-reduce operation
- MongoDB documentation
- map-reduce
 
- 
mapReduce@Deprecated <TResult> MapReduceIterable<TResult> mapReduce(String mapFunction, String reduceFunction, Class<TResult> resultClass) Deprecated.Superseded by aggregateAggregates 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.
- resultClass- the class to decode each resulting document into.
- Returns:
- an iterable containing the result of the map-reduce operation
- MongoDB documentation
- map-reduce
 
- 
mapReduce@Deprecated MapReduceIterable<TDocument> mapReduce(ClientSession clientSession, String mapFunction, String reduceFunction) Deprecated.Superseded by aggregateAggregates documents according to the specified map-reduce function.- Parameters:
- clientSession- the client session with which to associate this operation
- 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 iterable containing the result of the map-reduce operation
- Since:
- 3.6
- MongoDB documentation
- map-reduce
- Since server release
- 3.6
 
- 
mapReduce@Deprecated <TResult> MapReduceIterable<TResult> mapReduce(ClientSession clientSession, String mapFunction, String reduceFunction, Class<TResult> resultClass) Deprecated.Superseded by aggregateAggregates 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 operation
- 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.
- Returns:
- an iterable containing the result of the map-reduce operation
- Since:
- 3.6
- MongoDB documentation
- map-reduce
- Since server release
- 3.6
 
- 
bulkWriteExecutes a mix of inserts, updates, replaces, and deletes.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. The eligibility for retryable write support for bulk operations is determined on the whole bulk write. If the requestscontain anyUpdateManyModelsorDeleteManyModelsthen the bulk operation will not support retryable writes.- Parameters:
- requests- the writes to execute
- Returns:
- the result of the bulk write
- Throws:
- MongoBulkWriteException- if there's an exception in the bulk write operation
- MongoException- if there's an exception running the operation
 
- 
bulkWriteBulkWriteResult bulkWrite(List<? extends WriteModel<? extends TDocument>> requests, BulkWriteOptions options) Executes a mix of inserts, updates, replaces, and deletes.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. The eligibility for retryable write support for bulk operations is determined on the whole bulk write. If the requestscontain anyUpdateManyModelsorDeleteManyModelsthen the bulk operation will not support retryable writes.- Parameters:
- requests- the writes to execute
- options- the options to apply to the bulk write operation
- Returns:
- the result of the bulk write
- Throws:
- MongoBulkWriteException- if there's an exception in the bulk write operation
- MongoException- if there's an exception running the operation
 
- 
bulkWriteBulkWriteResult bulkWrite(ClientSession clientSession, List<? extends WriteModel<? extends TDocument>> requests) Executes a mix of inserts, updates, replaces, and deletes.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. The eligibility for retryable write support for bulk operations is determined on the whole bulk write. If the requestscontain anyUpdateManyModelsorDeleteManyModelsthen the bulk operation will not support retryable writes.- Parameters:
- clientSession- the client session with which to associate this operation
- requests- the writes to execute
- Returns:
- the result of the bulk write
- Throws:
- MongoBulkWriteException- if there's an exception in the bulk write operation
- MongoException- if there's an exception running the operation
- Since:
- 3.6
- Since server release
- 3.6
 
- 
bulkWriteBulkWriteResult bulkWrite(ClientSession clientSession, List<? extends WriteModel<? extends TDocument>> requests, BulkWriteOptions options) Executes a mix of inserts, updates, replaces, and deletes.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. The eligibility for retryable write support for bulk operations is determined on the whole bulk write. If the requestscontain anyUpdateManyModelsorDeleteManyModelsthen the bulk operation will not support retryable writes.- Parameters:
- clientSession- the client session with which to associate this operation
- requests- the writes to execute
- options- the options to apply to the bulk write operation
- Returns:
- the result of the bulk write
- Throws:
- MongoBulkWriteException- if there's an exception in the bulk write operation
- MongoException- if there's an exception running the operation
- Since:
- 3.6
- Since server release
- 3.6
 
- 
insertOneInserts the provided document. If the document is missing an identifier, the driver should generate one.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. - Parameters:
- document- the document to insert
- Returns:
- the insert one result
- Throws:
- MongoWriteException- if the write failed due to some specific write exception
- MongoWriteConcernException- if the write failed due to being unable to fulfil the write concern
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
 
- 
insertOneInserts the provided document. If the document is missing an identifier, the driver should generate one.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. - Parameters:
- document- the document to insert
- options- the options to apply to the operation
- Returns:
- the insert one result
- Throws:
- MongoWriteException- if the write failed due to some specific write exception
- MongoWriteConcernException- if the write failed due to being unable to fulfil the write concern
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
- Since:
- 3.2
 
- 
insertOneInserts the provided document. If the document is missing an identifier, the driver should generate one.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 operation
- document- the document to insert
- Returns:
- the insert one result
- Throws:
- MongoWriteException- if the write failed due to some specific write exception
- MongoWriteConcernException- if the write failed due to being unable to fulfil the write concern
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
- Since:
- 3.6
- Since server release
- 3.6
 
- 
insertOneInsertOneResult insertOne(ClientSession clientSession, TDocument document, InsertOneOptions options) Inserts the provided document. If the document is missing an identifier, the driver should generate one.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 operation
- document- the document to insert
- options- the options to apply to the operation
- Returns:
- the insert one result
- Throws:
- MongoWriteException- if the write failed due to some specific write exception
- MongoWriteConcernException- if the write failed due to being unable to fulfil the write concern
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
- Since:
- 3.6
- Since server release
- 3.6
 
- 
insertManyInserts one or more documents. A call to this method is equivalent to a call to thebulkWritemethodNote: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. - Parameters:
- documents- the documents to insert
- Returns:
- the insert many result
- Throws:
- MongoBulkWriteException- if there's an exception in the bulk write operation
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
- IllegalArgumentException- if the documents list is null or empty, or any of the documents in the list are null
- See Also:
 
- 
insertManyInserts one or more documents. A call to this method is equivalent to a call to thebulkWritemethodNote: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. - Parameters:
- documents- the documents to insert
- options- the options to apply to the operation
- Returns:
- the insert many result
- Throws:
- MongoBulkWriteException- if there's an exception in the bulk write operation
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
- IllegalArgumentException- if the documents list is null or empty, or any of the documents in the list are null
 
- 
insertManyInserts one or more documents. A call to this method is equivalent to a call to thebulkWritemethodNote: 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 operation
- documents- the documents to insert
- Returns:
- the insert many result
- Throws:
- MongoBulkWriteException- if there's an exception in the bulk write operation
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
- IllegalArgumentException- if the documents list is null or empty, or any of the documents in the list are null
- Since:
- 3.6
- See Also:
- Since server release
- 3.6
 
- 
insertManyInsertManyResult insertMany(ClientSession clientSession, List<? extends TDocument> documents, InsertManyOptions options) Inserts one or more documents. A call to this method is equivalent to a call to thebulkWritemethodNote: 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 operation
- documents- the documents to insert
- options- the options to apply to the operation
- Returns:
- the insert many result
- Throws:
- MongoBulkWriteException- if there's an exception in the bulk write operation
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
- IllegalArgumentException- if the documents list is null or empty, or any of the documents in the list are null
- Since:
- 3.6
- Since server release
- 3.6
 
- 
deleteOneRemoves at most one document from the collection that matches the given filter. If no documents match, the collection is not modified.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. - Parameters:
- filter- the query filter to apply the delete operation
- Returns:
- the result of the remove one operation
- Throws:
- MongoWriteException- if the write failed due to some specific write exception
- MongoWriteConcernException- if the write failed due to being unable to fulfil the write concern
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
 
- 
deleteOneRemoves at most one document from the collection that matches the given filter. If no documents match, the collection is not modified.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. - Parameters:
- filter- the query filter to apply the delete operation
- options- the options to apply to the delete operation
- Returns:
- the result of the remove one operation
- Throws:
- MongoWriteException- if the write failed due to some specific write exception
- MongoWriteConcernException- if the write failed due to being unable to fulfil the write concern
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
- Since:
- 3.4
 
- 
deleteOneRemoves at most one document from the collection that matches the given filter. If no documents match, the collection is not modified.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 operation
- filter- the query filter to apply the delete operation
- Returns:
- the result of the remove one operation
- Throws:
- MongoWriteException- if the write failed due to some specific write exception
- MongoWriteConcernException- if the write failed due to being unable to fulfil the write concern
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
- Since:
- 3.6
- Since server release
- 3.6
 
- 
deleteOneRemoves at most one document from the collection that matches the given filter. If no documents match, the collection is not modified.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 operation
- filter- the query filter to apply the delete operation
- options- the options to apply to the delete operation
- Returns:
- the result of the remove one operation
- Throws:
- MongoWriteException- if the write failed due to some specific write exception
- MongoWriteConcernException- if the write failed due to being unable to fulfil the write concern
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
- Since:
- 3.6
- Since server release
- 3.6
 
- 
deleteManyRemoves 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 delete operation
- Returns:
- the result of the remove many operation
- Throws:
- MongoWriteException- if the write failed due to some specific write exception
- MongoWriteConcernException- if the write failed due to being unable to fulfil the write concern
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
 
- 
deleteManyRemoves 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 delete operation
- options- the options to apply to the delete operation
- Returns:
- the result of the remove many operation
- Throws:
- MongoWriteException- if the write failed due to some specific write exception
- MongoWriteConcernException- if the write failed due to being unable to fulfil the write concern
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
- Since:
- 3.4
 
- 
deleteManyRemoves 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 operation
- filter- the query filter to apply the delete operation
- Returns:
- the result of the remove many operation
- Throws:
- MongoWriteException- if the write failed due to some specific write exception
- MongoWriteConcernException- if the write failed due to being unable to fulfil the write concern
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
- Since:
- 3.6
- Since server release
- 3.6
 
- 
deleteManyRemoves 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 operation
- filter- the query filter to apply the delete operation
- options- the options to apply to the delete operation
- Returns:
- the result of the remove many operation
- Throws:
- MongoWriteException- if the write failed due to some specific write exception
- MongoWriteConcernException- if the write failed due to being unable to fulfil the write concern
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
- Since:
- 3.6
- Since server release
- 3.6
 
- 
replaceOneReplace a document in the collection according to the specified arguments.Use this method to replace a document using the specified replacement argument. To update the document with update operators, use the corresponding updateOne(Bson, Bson)method.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. - Parameters:
- filter- the query filter to apply the replace operation
- replacement- the replacement document
- Returns:
- the result of the replace one operation
- Throws:
- MongoWriteException- if the write failed due to some specific write exception
- MongoWriteConcernException- if the write failed due to being unable to fulfil the write concern
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
- MongoDB documentation
- Replace
- Update Command Behaviors
 
- 
replaceOneReplace a document in the collection according to the specified arguments.Use this method to replace a document using the specified replacement argument. To update the document with update operators, use the corresponding updateOne(Bson, Bson, UpdateOptions)method.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. - Parameters:
- filter- the query filter to apply the replace operation
- replacement- the replacement document
- replaceOptions- the options to apply to the replace operation
- Returns:
- the result of the replace one operation
- Throws:
- MongoWriteException- if the write failed due to some specific write exception
- MongoWriteConcernException- if the write failed due to being unable to fulfil the write concern
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
- Since:
- 3.7
- MongoDB documentation
- Replace
- Update Command Behaviors
 
- 
replaceOneReplace a document in the collection according to the specified arguments.Use this method to replace a document using the specified replacement argument. To update the document with update operators, use the corresponding updateOne(ClientSession, Bson, Bson)method.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 operation
- filter- the query filter to apply the replace operation
- replacement- the replacement document
- Returns:
- the result of the replace one operation
- Throws:
- MongoWriteException- if the write failed due to some specific write exception
- MongoWriteConcernException- if the write failed due to being unable to fulfil the write concern
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
- Since:
- 3.6
- MongoDB documentation
- Replace
- Update Command Behaviors
- Since server release
- 3.6
 
- 
replaceOneUpdateResult replaceOne(ClientSession clientSession, Bson filter, TDocument replacement, ReplaceOptions replaceOptions) Replace a document in the collection according to the specified arguments.Use this method to replace a document using the specified replacement argument. To update the document with update operators, use the corresponding updateOne(ClientSession, Bson, Bson, UpdateOptions)method.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 operation
- filter- the query filter to apply the replace operation
- replacement- the replacement document
- replaceOptions- the options to apply to the replace operation
- Returns:
- the result of the replace one operation
- Throws:
- MongoWriteException- if the write failed due to some specific write exception
- MongoWriteConcernException- if the write failed due to being unable to fulfil the write concern
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
- Since:
- 3.7
- MongoDB documentation
- Replace
- Update Command Behaviors
- Since server release
- 3.6
 
- 
updateOneUpdate a single document in the collection according to the specified arguments.Use this method to only update the corresponding fields in the document according to the update operators used in the update document. To replace the entire document with a new document, use the corresponding replaceOne(Bson, Object)method.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 document describing the update, which may not be null. The update to apply must include at least one update operator.
- Returns:
- the result of the update one operation
- Throws:
- MongoWriteException- if the write failed due to some specific write exception
- MongoWriteConcernException- if the write failed due to being unable to fulfil the write concern
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
- See Also:
- MongoDB documentation
- Updates
- Update Operators
- Update Command Behaviors
 
- 
updateOneUpdate a single document in the collection according to the specified arguments.Use this method to only update the corresponding fields in the document according to the update operators used in the update document. To replace the entire document with a new document, use the corresponding replaceOne(Bson, Object, ReplaceOptions)method.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 document describing the update, which may not be null. The update to apply must include at least one update operator.
- updateOptions- the options to apply to the update operation
- Returns:
- the result of the update one operation
- Throws:
- MongoWriteException- if the write failed due to some specific write exception
- MongoWriteConcernException- if the write failed due to being unable to fulfil the write concern
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
- See Also:
- MongoDB documentation
- Updates
- Update Operators
- Update Command Behaviors
 
- 
updateOneUpdate a single document in the collection according to the specified arguments.Use this method to only update the corresponding fields in the document according to the update operators used in the update document. To replace the entire document with a new document, use the corresponding replaceOne(ClientSession, Bson, Object)method.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 operation
- 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 at least one update operator.
- Returns:
- the result of the update one operation
- Throws:
- MongoWriteException- if the write failed due to some specific write exception
- MongoWriteConcernException- if the write failed due to being unable to fulfil the write concern
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
- Since:
- 3.6
- See Also:
- MongoDB documentation
- Updates
- Update Operators
- Update Command Behaviors
- Since server release
- 3.6
 
- 
updateOneUpdateResult updateOne(ClientSession clientSession, Bson filter, Bson update, UpdateOptions updateOptions) Update a single document in the collection according to the specified arguments.Use this method to only update the corresponding fields in the document according to the update operators used in the update document. To replace the entire document with a new document, use the corresponding replaceOne(ClientSession, Bson, Object, ReplaceOptions)method.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 operation
- 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 at least one update operator.
- updateOptions- the options to apply to the update operation
- Returns:
- the result of the update one operation
- Throws:
- MongoWriteException- if the write failed due to some specific write exception
- MongoWriteConcernException- if the write failed due to being unable to fulfil the write concern
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
- Since:
- 3.6
- See Also:
- MongoDB documentation
- Updates
- Update Operators
- Update Command Behaviors
- Since server release
- 3.6
 
- 
updateOneUpdate 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:
- the result of the update one operation
- Throws:
- MongoWriteException- if the write failed due some other failure specific to the update command
- MongoWriteConcernException- if the write failed due being unable to fulfil the write concern
- MongoException- if the write failed due some other failure
- Since:
- 3.11
- MongoDB documentation
- Updates
- Update Operators
- Since server release
- 4.2
 
- 
updateOneUpdate 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.
- updateOptions- the options to apply to the update operation
- Returns:
- the result of the update one operation
- Throws:
- MongoWriteException- if the write failed due some other failure specific to the update command
- MongoWriteConcernException- if the write failed due being unable to fulfil the write concern
- MongoException- if the write failed due some other failure
- Since:
- 3.11
- MongoDB documentation
- Updates
- Update Operators
- Since server release
- 4.2
 
- 
updateOneUpdate 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 operation
- filter- a document describing the query filter, which may not be null.
- update- a pipeline describing the update, which may not be null.
- Returns:
- the result of the update one operation
- Throws:
- MongoWriteException- if the write failed due some other failure specific to the update command
- MongoWriteConcernException- if the write failed due being unable to fulfil the write concern
- MongoException- if the write failed due some other failure
- Since:
- 3.11
- MongoDB documentation
- Updates
- Update Operators
- Since server release
- 4.2
 
- 
updateOneUpdateResult updateOne(ClientSession clientSession, Bson filter, List<? extends Bson> update, UpdateOptions updateOptions) 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 operation
- filter- a document describing the query filter, which may not be null.
- update- a pipeline describing the update, which may not be null.
- updateOptions- the options to apply to the update operation
- Returns:
- the result of the update one operation
- Throws:
- MongoWriteException- if the write failed due some other failure specific to the update command
- MongoWriteConcernException- if the write failed due being unable to fulfil the write concern
- MongoException- if the write failed due some other failure
- Since:
- 3.11
- MongoDB documentation
- Updates
- Update Operators
- Since server release
- 4.2
 
- 
updateManyUpdate 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:
- the result of the update many operation
- Throws:
- MongoWriteException- if the write failed due to some specific write exception
- MongoWriteConcernException- if the write failed due to being unable to fulfil the write concern
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
- MongoDB documentation
- Updates
- Update Operators
 
- 
updateManyUpdate 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.
- updateOptions- the options to apply to the update operation
- Returns:
- the result of the update many operation
- Throws:
- MongoWriteException- if the write failed due to some specific write exception
- MongoWriteConcernException- if the write failed due to being unable to fulfil the write concern
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
- MongoDB documentation
- Updates
- Update Operators
 
- 
updateManyUpdate all documents in the collection according to the specified arguments.- Parameters:
- clientSession- the client session with which to associate this operation
- 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:
- the result of the update many operation
- Throws:
- MongoWriteException- if the write failed due to some specific write exception
- MongoWriteConcernException- if the write failed due to being unable to fulfil the write concern
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
- Since:
- 3.6
- MongoDB documentation
- Updates
- Update Operators
- Since server release
- 3.6
 
- 
updateManyUpdateResult updateMany(ClientSession clientSession, Bson filter, Bson update, UpdateOptions updateOptions) Update all documents in the collection according to the specified arguments.- Parameters:
- clientSession- the client session with which to associate this operation
- 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 operation
- Returns:
- the result of the update many operation
- Throws:
- MongoWriteException- if the write failed due to some specific write exception
- MongoWriteConcernException- if the write failed due to being unable to fulfil the write concern
- MongoCommandException- if the write failed due to a specific command exception
- MongoException- if the write failed due some other failure
- Since:
- 3.6
- MongoDB documentation
- Updates
- Update Operators
- Since server release
- 3.6
 
- 
updateManyUpdate 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:
- the result of the update many operation
- Throws:
- MongoWriteException- if the write failed due some other failure specific to the update command
- MongoWriteConcernException- if the write failed due being unable to fulfil the write concern
- MongoException- if the write failed due some other failure
- Since:
- 3.11
- MongoDB documentation
- Updates
- Update Operators
- Since server release
- 4.2
 
- 
updateManyUpdate 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.
- updateOptions- the options to apply to the update operation
- Returns:
- the result of the update many operation
- Throws:
- MongoWriteException- if the write failed due some other failure specific to the update command
- MongoWriteConcernException- if the write failed due being unable to fulfil the write concern
- MongoException- if the write failed due some other failure
- Since:
- 3.11
- MongoDB documentation
- Updates
- Update Operators
- Since server release
- 4.2
 
- 
updateManyUpdate all documents in the collection according to the specified arguments.- Parameters:
- clientSession- the client session with which to associate this operation
- filter- a document describing the query filter, which may not be null.
- update- a pipeline describing the update, which may not be null.
- Returns:
- the result of the update many operation
- Throws:
- MongoWriteException- if the write failed due some other failure specific to the update command
- MongoWriteConcernException- if the write failed due being unable to fulfil the write concern
- MongoException- if the write failed due some other failure
- Since:
- 3.11
- MongoDB documentation
- Updates
- Update Operators
- Since server release
- 4.2
 
- 
updateManyUpdateResult updateMany(ClientSession clientSession, Bson filter, List<? extends Bson> update, UpdateOptions updateOptions) Update all documents in the collection according to the specified arguments.- Parameters:
- clientSession- the client session with which to associate this operation
- filter- a document describing the query filter, which may not be null.
- update- a pipeline describing the update, which may not be null.
- updateOptions- the options to apply to the update operation
- Returns:
- the result of the update many operation
- Throws:
- MongoWriteException- if the write failed due some other failure specific to the update command
- MongoWriteConcernException- if the write failed due being unable to fulfil the write concern
- MongoException- if the write failed due some other failure
- Since:
- 3.11
- MongoDB documentation
- Updates
- Update Operators
- Since server release
- 4.2
 
- 
findOneAndDeleteAtomically find a document and remove it.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. - Parameters:
- filter- the query filter to find the document with
- Returns:
- the document that was removed. If no documents matched the query filter, then null will be returned
 
- 
findOneAndDeleteAtomically find a document and remove it.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. - Parameters:
- filter- the query filter to find the document with
- options- the options to apply to the operation
- Returns:
- the document that was removed. If no documents matched the query filter, then null will be returned
 
- 
findOneAndDeleteAtomically find a document and remove 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 operation
- filter- the query filter to find the document with
- Returns:
- the document that was removed. If no documents matched the query filter, then null will be returned
- Since:
- 3.6
- Since server release
- 3.6
 
- 
findOneAndDelete@Nullable TDocument findOneAndDelete(ClientSession clientSession, Bson filter, FindOneAndDeleteOptions options) Atomically find a document and remove 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 operation
- filter- the query filter to find the document with
- options- the options to apply to the operation
- Returns:
- the document that was removed. If no documents matched the query filter, then null will be returned
- Since:
- 3.6
- Since server release
- 3.6
 
- 
findOneAndReplaceAtomically find a document and replace it.Use this method to replace a document using the specified replacement argument. To update the document with update operators, use the corresponding findOneAndUpdate(Bson, Bson)method.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. - Parameters:
- filter- the query filter to apply the replace operation
- replacement- the replacement document
- Returns:
- the document that was replaced.  Depending on the value of the returnOriginalproperty, 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
- MongoDB documentation
- Update Command Behaviors
 
- 
findOneAndReplace@Nullable TDocument findOneAndReplace(Bson filter, TDocument replacement, FindOneAndReplaceOptions options) Atomically find a document and replace it.Use this method to replace a document using the specified replacement argument. To update the document with update operators, use the corresponding findOneAndUpdate(Bson, Bson, FindOneAndUpdateOptions)method.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. - Parameters:
- filter- the query filter to apply the replace operation
- replacement- the replacement document
- options- the options to apply to the operation
- Returns:
- the document that was replaced.  Depending on the value of the returnOriginalproperty, 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
- MongoDB documentation
- Update Command Behaviors
 
- 
findOneAndReplace@Nullable TDocument findOneAndReplace(ClientSession clientSession, Bson filter, TDocument replacement) Atomically find a document and replace it.Use this method to replace a document using the specified replacement argument. To update the document with update operators, use the corresponding findOneAndUpdate(ClientSession, Bson, Bson)method.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 operation
- filter- the query filter to apply the replace operation
- replacement- the replacement document
- Returns:
- the document that was replaced.  Depending on the value of the returnOriginalproperty, 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:
- 3.6
- MongoDB documentation
- Update Command Behaviors
- Since server release
- 3.6
 
- 
findOneAndReplace@Nullable TDocument findOneAndReplace(ClientSession clientSession, Bson filter, TDocument replacement, FindOneAndReplaceOptions options) Atomically find a document and replace it.Use this method to replace a document using the specified replacement argument. To update the document with update operators, use the corresponding findOneAndUpdate(ClientSession, Bson, Bson, FindOneAndUpdateOptions)method.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 operation
- filter- the query filter to apply the replace operation
- replacement- the replacement document
- options- the options to apply to the operation
- Returns:
- the document that was replaced.  Depending on the value of the returnOriginalproperty, 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:
- 3.6
- MongoDB documentation
- Update Command Behaviors
- Since server release
- 3.6
 
- 
findOneAndUpdateAtomically find a document and update it.Use this method to only update the corresponding fields in the document according to the update operators used in the update document. To replace the entire document with a new document, use the corresponding findOneAndReplace(Bson, Object)method.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 document describing the update, which may not be null. The update to apply must include at least one update operator.
- Returns:
- the document that was updated before the update was applied. If no documents matched the query filter, then null will be returned
- See Also:
- MongoDB documentation
- Update Command Behaviors
 
- 
findOneAndUpdateAtomically find a document and update it.Use this method to only update the corresponding fields in the document according to the update operators used in the update document. To replace the entire document with a new document, use the corresponding findOneAndReplace(Bson, Object, FindOneAndReplaceOptions)method.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 document describing the update, which may not be null. The update to apply must include at least one update operator.
- options- the options to apply to the operation
- Returns:
- the document that was updated.  Depending on the value of the returnOriginalproperty, 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
- See Also:
- MongoDB documentation
- Update Command Behaviors
 
- 
findOneAndUpdateAtomically find a document and update it.Use this method to only update the corresponding fields in the document according to the update operators used in the update document. To replace the entire document with a new document, use the corresponding findOneAndReplace(ClientSession, Bson, Object)method.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 operation
- 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 at least one update operator.
- Returns:
- the document that was updated before the update was applied. If no documents matched the query filter, then null will be returned
- Since:
- 3.6
- See Also:
- MongoDB documentation
- Update Command Behaviors
- Since server release
- 3.6
 
- 
findOneAndUpdate@Nullable TDocument findOneAndUpdate(ClientSession clientSession, Bson filter, Bson update, FindOneAndUpdateOptions options) Atomically find a document and update it.Use this method to only update the corresponding fields in the document according to the update operators used in the update document. To replace the entire document with a new document, use the corresponding findOneAndReplace(ClientSession, Bson, Object, FindOneAndReplaceOptions)method.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 operation
- 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 at least one update operator.
- options- the options to apply to the operation
- Returns:
- the document that was updated.  Depending on the value of the returnOriginalproperty, 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:
- 3.6
- See Also:
- MongoDB documentation
- Update Command Behaviors
- Since server release
- 3.6
 
- 
findOneAndUpdateAtomically 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:
- the document that was updated before the update was applied. If no documents matched the query filter, then null will be returned
- Since:
- 3.11
- Since server release
- 4.2
 
- 
findOneAndUpdate@Nullable 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:
- the document that was updated.  Depending on the value of the returnOriginalproperty, 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:
- 3.11
- Since server release
- 4.2
 
- 
findOneAndUpdate@Nullable 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 operation
- filter- a document describing the query filter, which may not be null.
- update- a pipeline describing the update, which may not be null.
- Returns:
- the document that was updated before the update was applied. If no documents matched the query filter, then null will be returned
- Since:
- 3.11
- Since server release
- 4.2
 
- 
findOneAndUpdate@Nullable 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 operation
- 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:
- the document that was updated.  Depending on the value of the returnOriginalproperty, 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:
- 3.11
- Since server release
- 4.2
 
- 
dropvoid drop()Drops this collection from the Database.- MongoDB documentation
- Drop Collection
 
- 
dropDrops this collection from the Database.- Parameters:
- clientSession- the client session with which to associate this operation
- Since:
- 3.6
- MongoDB documentation
- Drop Collection
- Since server release
- 3.6
 
- 
dropDrops this collection from the Database.- Parameters:
- dropCollectionOptions- various options for dropping the collection
- Since:
- 4.7
- MongoDB documentation
- Drop Collection
- Since server release
- 6.0
 
- 
dropDrops this collection from the Database.- Parameters:
- clientSession- the client session with which to associate this operation
- dropCollectionOptions- various options for dropping the collection
- Since:
- 4.7
- MongoDB documentation
- Drop Collection
- Since server release
- 6.0
 
- 
createSearchIndexCreate an Atlas Search index for the collection.- Parameters:
- indexName- the name of the search index to create.
- definition- the search index mapping definition.
- Returns:
- the search index name.
- Since:
- 4.11
- MongoDB documentation
- Create Search indexes
- Since server release
- 7.0
 
- 
createSearchIndexCreate an Atlas Search index with"default"name for the collection.- Parameters:
- definition- the search index mapping definition.
- Returns:
- the search index name.
- Since:
- 4.11
- MongoDB documentation
- Create Search indexes
- Since server release
- 7.0
 
- 
createSearchIndexesCreate one or more Atlas Search indexes for the collection.The name can be omitted for a single index, in which case a name will be "default".- Parameters:
- searchIndexModels- the search index models.
- Returns:
- the search index names in the order specified by the given list of SearchIndexModels.
- Since:
- 4.11
- MongoDB documentation
- Create Search indexes
- Since server release
- 7.0
 
- 
updateSearchIndexUpdate an Atlas Search index in the collection.- Parameters:
- indexName- the name of the search index to update.
- definition- the search index mapping definition.
- Since:
- 4.11
- MongoDB documentation
- Update Search index
- Since server release
- 7.0
 
- 
dropSearchIndexDrop an Atlas Search index given its name.- Parameters:
- indexName- the name of the search index to drop.
- Since:
- 4.11
- MongoDB documentation
- Drop Search index
- Since server release
- 7.0
 
- 
listSearchIndexesListSearchIndexesIterable<Document> listSearchIndexes()Get all Atlas Search indexes in this collection.- Returns:
- the list search indexes iterable interface.
- Since:
- 4.11
- Since server release
- 7.0
 
- 
listSearchIndexesGet all Atlas Search indexes in this collection.- Type Parameters:
- TResult- the target document type of the iterable.
- Parameters:
- resultClass- the class to decode each document into.
- Returns:
- the list search indexes iterable interface.
- Since:
- 4.11
- Since server release
- 7.0
 
- 
createIndexCreate an index with the given keys.- Parameters:
- keys- an object describing the index key(s), which may not be null.
- Returns:
- the index name
- MongoDB documentation
- Create indexes
 
- 
createIndexCreate an index with the given keys and options.- Parameters:
- keys- an object describing the index key(s), which may not be null.
- indexOptions- the options for the index
- Returns:
- the index name
- MongoDB documentation
- Create indexes
 
- 
createIndexCreate an index with the given keys.- Parameters:
- clientSession- the client session with which to associate this operation
- keys- an object describing the index key(s), which may not be null.
- Returns:
- the index name
- Since:
- 3.6
- MongoDB documentation
- Create indexes
- Since server release
- 3.6
 
- 
createIndexCreate an index with the given keys and options.- Parameters:
- clientSession- the client session with which to associate this operation
- keys- an object describing the index key(s), which may not be null.
- indexOptions- the options for the index
- Returns:
- the index name
- Since:
- 3.6
- MongoDB documentation
- Create indexes
- Since server release
- 3.6
 
- 
createIndexesCreate multiple indexes.- Parameters:
- indexes- the list of indexes
- Returns:
- the list of index names
- MongoDB documentation
- Create indexes
 
- 
createIndexesCreate multiple indexes.- Parameters:
- indexes- the list of indexes
- createIndexOptions- options to use when creating indexes
- Returns:
- the list of index names
- Since:
- 3.6
- MongoDB documentation
- Create indexes
 
- 
createIndexesCreate multiple indexes.- Parameters:
- clientSession- the client session with which to associate this operation
- indexes- the list of indexes
- Returns:
- the list of index names
- Since:
- 3.6
- MongoDB documentation
- Create indexes
- Since server release
- 3.6
 
- 
createIndexesList<String> createIndexes(ClientSession clientSession, List<IndexModel> indexes, CreateIndexOptions createIndexOptions) Create multiple indexes.- Parameters:
- clientSession- the client session with which to associate this operation
- indexes- the list of indexes
- createIndexOptions- options to use when creating indexes
- Returns:
- the list of index names
- Since:
- 3.6
- MongoDB documentation
- Create indexes
- Since server release
- 3.6
 
- 
listIndexesListIndexesIterable<Document> listIndexes()Get all the indexes in this collection.- Returns:
- the list indexes iterable interface
- MongoDB documentation
- List indexes
 
- 
listIndexesGet all the indexes in this collection.- Type Parameters:
- TResult- the target document type of the iterable.
- Parameters:
- resultClass- the class to decode each document into
- Returns:
- the list indexes iterable interface
- MongoDB documentation
- List indexes
 
- 
listIndexesGet all the indexes in this collection.- Parameters:
- clientSession- the client session with which to associate this operation
- Returns:
- the list indexes iterable interface
- Since:
- 3.6
- MongoDB documentation
- List indexes
- Since server release
- 3.6
 
- 
listIndexes<TResult> ListIndexesIterable<TResult> listIndexes(ClientSession clientSession, Class<TResult> resultClass) 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 operation
- resultClass- the class to decode each document into
- Returns:
- the list indexes iterable interface
- Since:
- 3.6
- MongoDB documentation
- List indexes
- Since server release
- 3.6
 
- 
dropIndexDrops the index given its name.- Parameters:
- indexName- the name of the index to remove
- MongoDB documentation
- Drop indexes
 
- 
dropIndexDrops the index given its name.- Parameters:
- indexName- the name of the index to remove
- dropIndexOptions- the options to use when dropping indexes
- Since:
- 3.6
- MongoDB documentation
- Drop indexes
 
- 
dropIndexDrops the index given the keys used to create it.- Parameters:
- keys- the keys of the index to remove
- MongoDB documentation
- Drop indexes
 
- 
dropIndexDrops the index given the keys used to create it.- Parameters:
- keys- the keys of the index to remove
- dropIndexOptions- the options to use when dropping indexes
- Since:
- 3.6
- MongoDB documentation
- Drop indexes
 
- 
dropIndexDrops the index given its name.- Parameters:
- clientSession- the client session with which to associate this operation
- indexName- the name of the index to remove
- Since:
- 3.6
- MongoDB documentation
- Drop indexes
- Since server release
- 3.6
 
- 
dropIndexDrops the index given the keys used to create it.- Parameters:
- clientSession- the client session with which to associate this operation
- keys- the keys of the index to remove
- Since:
- 3.6
- MongoDB documentation
- Drop indexes
- Since server release
- 3.6
 
- 
dropIndexDrops the index given its name.- Parameters:
- clientSession- the client session with which to associate this operation
- indexName- the name of the index to remove
- dropIndexOptions- the options to use when dropping indexes
- Since:
- 3.6
- MongoDB documentation
- Drop indexes
- Since server release
- 3.6
 
- 
dropIndexDrops the index given the keys used to create it.- Parameters:
- clientSession- the client session with which to associate this operation
- keys- the keys of the index to remove
- dropIndexOptions- the options to use when dropping indexes
- Since:
- 3.6
- MongoDB documentation
- Drop indexes
- Since server release
- 3.6
 
- 
dropIndexesvoid dropIndexes()Drop all the indexes on this collection, except for the default on _id.- MongoDB documentation
- Drop indexes
 
- 
dropIndexesDrop all the indexes on this collection, except for the default on _id.- Parameters:
- clientSession- the client session with which to associate this operation
- Since:
- 3.6
- MongoDB documentation
- Drop indexes
- Since server release
- 3.6
 
- 
dropIndexesDrop all the indexes on this collection, except for the default on _id.- Parameters:
- dropIndexOptions- the options to use when dropping indexes
- Since:
- 3.6
- MongoDB documentation
- Drop indexes
 
- 
dropIndexesDrop all the indexes on this collection, except for the default on _id.- Parameters:
- clientSession- the client session with which to associate this operation
- dropIndexOptions- the options to use when dropping indexes
- Since:
- 3.6
- MongoDB documentation
- Drop indexes
- Since server release
- 3.6
 
- 
renameCollectionRename the collection with oldCollectionName to the newCollectionName.- Parameters:
- newCollectionNamespace- the namespace the collection will be renamed to
- Throws:
- MongoServerException- 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 exist
- MongoDB documentation
- Rename collection
 
- 
renameCollectionvoid renameCollection(MongoNamespace newCollectionNamespace, RenameCollectionOptions renameCollectionOptions) Rename the collection with oldCollectionName to the newCollectionName.- Parameters:
- newCollectionNamespace- the name the collection will be renamed to
- renameCollectionOptions- the options for renaming a collection
- Throws:
- MongoServerException- 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
- MongoDB documentation
- Rename collection
 
- 
renameCollectionRename the collection with oldCollectionName to the newCollectionName.- Parameters:
- clientSession- the client session with which to associate this operation
- newCollectionNamespace- the namespace the collection will be renamed to
- Throws:
- MongoServerException- 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 exist
- Since:
- 3.6
- MongoDB documentation
- Rename collection
- Since server release
- 3.6
 
- 
renameCollectionvoid renameCollection(ClientSession clientSession, MongoNamespace newCollectionNamespace, RenameCollectionOptions renameCollectionOptions) Rename the collection with oldCollectionName to the newCollectionName.- Parameters:
- clientSession- the client session with which to associate this operation
- newCollectionNamespace- the name the collection will be renamed to
- renameCollectionOptions- the options for renaming a collection
- Throws:
- MongoServerException- 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
- Since:
- 3.6
- MongoDB documentation
- Rename collection
- Since server release
- 3.6
 
 
-