Interface MongoCollection<TDocument>
-
- Type Parameters:
TDocument
- The type that this collection will encode documents from and decode documents to.
@ThreadSafe @Deprecated(since="2021-05-27") public interface MongoCollection<TDocument>
Deprecated.Usage of this API is not supported in AEM as a Cloud Service.The MongoCollection interface.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 theCodecRegistry
.- Since:
- 3.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description AggregateIterable<TDocument>
aggregate(ClientSession clientSession, java.util.List<? extends Bson> pipeline)
Deprecated.Aggregates documents according to the specified aggregation pipeline.<TResult> AggregateIterable<TResult>
aggregate(ClientSession clientSession, java.util.List<? extends Bson> pipeline, java.lang.Class<TResult> resultClass)
Deprecated.Aggregates documents according to the specified aggregation pipeline.AggregateIterable<TDocument>
aggregate(java.util.List<? extends Bson> pipeline)
Deprecated.Aggregates documents according to the specified aggregation pipeline.<TResult> AggregateIterable<TResult>
aggregate(java.util.List<? extends Bson> pipeline, java.lang.Class<TResult> resultClass)
Deprecated.Aggregates documents according to the specified aggregation pipeline.BulkWriteResult
bulkWrite(ClientSession clientSession, java.util.List<? extends WriteModel<? extends TDocument>> requests)
Deprecated.Executes a mix of inserts, updates, replaces, and deletes.BulkWriteResult
bulkWrite(ClientSession clientSession, java.util.List<? extends WriteModel<? extends TDocument>> requests, BulkWriteOptions options)
Deprecated.Executes a mix of inserts, updates, replaces, and deletes.BulkWriteResult
bulkWrite(java.util.List<? extends WriteModel<? extends TDocument>> requests)
Deprecated.Executes a mix of inserts, updates, replaces, and deletes.BulkWriteResult
bulkWrite(java.util.List<? extends WriteModel<? extends TDocument>> requests, BulkWriteOptions options)
Deprecated.Executes a mix of inserts, updates, replaces, and deletes.long
count()
Deprecated.usecountDocuments()
orestimatedDocumentCount()
insteadlong
count(ClientSession clientSession)
Deprecated.usecountDocuments(ClientSession)
insteadlong
count(ClientSession clientSession, Bson filter)
Deprecated.usecountDocuments(ClientSession, Bson)
insteadlong
count(ClientSession clientSession, Bson filter, CountOptions options)
Deprecated.long
count(Bson filter)
Deprecated.usecountDocuments(Bson)
insteadlong
count(Bson filter, CountOptions options)
Deprecated.usecountDocuments(Bson, CountOptions)
insteadlong
countDocuments()
Deprecated.Counts the number of documents in the collection.long
countDocuments(ClientSession clientSession)
Deprecated.Counts the number of documents in the collection.long
countDocuments(ClientSession clientSession, Bson filter)
Deprecated.Counts the number of documents in the collection according to the given options.long
countDocuments(ClientSession clientSession, Bson filter, CountOptions options)
Deprecated.Counts the number of documents in the collection according to the given options.long
countDocuments(Bson filter)
Deprecated.Counts the number of documents in the collection according to the given options.long
countDocuments(Bson filter, CountOptions options)
Deprecated.Counts the number of documents in the collection according to the given options.java.lang.String
createIndex(ClientSession clientSession, Bson keys)
Deprecated.Create an index with the given keys.java.lang.String
createIndex(ClientSession clientSession, Bson keys, IndexOptions indexOptions)
Deprecated.Create an index with the given keys and options.java.lang.String
createIndex(Bson keys)
Deprecated.Create an index with the given keys.java.lang.String
createIndex(Bson keys, IndexOptions indexOptions)
Deprecated.Create an index with the given keys and options.java.util.List<java.lang.String>
createIndexes(ClientSession clientSession, java.util.List<IndexModel> indexes)
Deprecated.Create multiple indexes.java.util.List<java.lang.String>
createIndexes(ClientSession clientSession, java.util.List<IndexModel> indexes, CreateIndexOptions createIndexOptions)
Deprecated.Create multiple indexes.java.util.List<java.lang.String>
createIndexes(java.util.List<IndexModel> indexes)
Deprecated.Create multiple indexes.java.util.List<java.lang.String>
createIndexes(java.util.List<IndexModel> indexes, CreateIndexOptions createIndexOptions)
Deprecated.Create multiple indexes.DeleteResult
deleteMany(ClientSession clientSession, Bson filter)
Deprecated.Removes all documents from the collection that match the given query filter.DeleteResult
deleteMany(ClientSession clientSession, Bson filter, DeleteOptions options)
Deprecated.Removes all documents from the collection that match the given query filter.DeleteResult
deleteMany(Bson filter)
Deprecated.Removes all documents from the collection that match the given query filter.DeleteResult
deleteMany(Bson filter, DeleteOptions options)
Deprecated.Removes all documents from the collection that match the given query filter.DeleteResult
deleteOne(ClientSession clientSession, Bson filter)
Deprecated.Removes at most one document from the collection that matches the given filter.DeleteResult
deleteOne(ClientSession clientSession, Bson filter, DeleteOptions options)
Deprecated.Removes at most one document from the collection that matches the given filter.DeleteResult
deleteOne(Bson filter)
Deprecated.Removes at most one document from the collection that matches the given filter.DeleteResult
deleteOne(Bson filter, DeleteOptions options)
Deprecated.Removes at most one document from the collection that matches the given filter.<TResult> DistinctIterable<TResult>
distinct(ClientSession clientSession, java.lang.String fieldName, java.lang.Class<TResult> resultClass)
Deprecated.Gets the distinct values of the specified field name.<TResult> DistinctIterable<TResult>
distinct(ClientSession clientSession, java.lang.String fieldName, Bson filter, java.lang.Class<TResult> resultClass)
Deprecated.Gets the distinct values of the specified field name.<TResult> DistinctIterable<TResult>
distinct(java.lang.String fieldName, java.lang.Class<TResult> resultClass)
Deprecated.Gets the distinct values of the specified field name.<TResult> DistinctIterable<TResult>
distinct(java.lang.String fieldName, Bson filter, java.lang.Class<TResult> resultClass)
Deprecated.Gets the distinct values of the specified field name.void
drop()
Deprecated.Drops this collection from the Database.void
drop(ClientSession clientSession)
Deprecated.Drops this collection from the Database.void
dropIndex(ClientSession clientSession, java.lang.String indexName)
Deprecated.Drops the index given its name.void
dropIndex(ClientSession clientSession, java.lang.String indexName, DropIndexOptions dropIndexOptions)
Deprecated.Drops the index given its name.void
dropIndex(ClientSession clientSession, Bson keys)
Deprecated.Drops the index given the keys used to create it.void
dropIndex(ClientSession clientSession, Bson keys, DropIndexOptions dropIndexOptions)
Deprecated.Drops the index given the keys used to create it.void
dropIndex(java.lang.String indexName)
Deprecated.Drops the index given its name.void
dropIndex(java.lang.String indexName, DropIndexOptions dropIndexOptions)
Deprecated.Drops the index given its name.void
dropIndex(Bson keys)
Deprecated.Drops the index given the keys used to create it.void
dropIndex(Bson keys, DropIndexOptions dropIndexOptions)
Deprecated.Drops the index given the keys used to create it.void
dropIndexes()
Deprecated.Drop all the indexes on this collection, except for the default on _id.void
dropIndexes(ClientSession clientSession)
Deprecated.Drop all the indexes on this collection, except for the default on _id.void
dropIndexes(ClientSession clientSession, DropIndexOptions dropIndexOptions)
Deprecated.Drop all the indexes on this collection, except for the default on _id.void
dropIndexes(DropIndexOptions dropIndexOptions)
Deprecated.Drop all the indexes on this collection, except for the default on _id.long
estimatedDocumentCount()
Deprecated.Gets an estimate of the count of documents in a collection using collection metadata.long
estimatedDocumentCount(EstimatedDocumentCountOptions options)
Deprecated.Gets an estimate of the count of documents in a collection using collection metadata.FindIterable<TDocument>
find()
Deprecated.Finds all documents in the collection.FindIterable<TDocument>
find(ClientSession clientSession)
Deprecated.Finds all documents in the collection.<TResult> FindIterable<TResult>
find(ClientSession clientSession, java.lang.Class<TResult> resultClass)
Deprecated.Finds all documents in the collection.FindIterable<TDocument>
find(ClientSession clientSession, Bson filter)
Deprecated.Finds all documents in the collection.<TResult> FindIterable<TResult>
find(ClientSession clientSession, Bson filter, java.lang.Class<TResult> resultClass)
Deprecated.Finds all documents in the collection.<TResult> FindIterable<TResult>
find(java.lang.Class<TResult> resultClass)
Deprecated.Finds all documents in the collection.FindIterable<TDocument>
find(Bson filter)
Deprecated.Finds all documents in the collection.<TResult> FindIterable<TResult>
find(Bson filter, java.lang.Class<TResult> resultClass)
Deprecated.Finds all documents in the collection.TDocument
findOneAndDelete(ClientSession clientSession, Bson filter)
Deprecated.Atomically find a document and remove it.TDocument
findOneAndDelete(ClientSession clientSession, Bson filter, FindOneAndDeleteOptions options)
Deprecated.Atomically find a document and remove it.TDocument
findOneAndDelete(Bson filter)
Deprecated.Atomically find a document and remove it.TDocument
findOneAndDelete(Bson filter, FindOneAndDeleteOptions options)
Deprecated.Atomically find a document and remove it.TDocument
findOneAndReplace(ClientSession clientSession, Bson filter, TDocument replacement)
Deprecated.Atomically find a document and replace it.TDocument
findOneAndReplace(ClientSession clientSession, Bson filter, TDocument replacement, FindOneAndReplaceOptions options)
Deprecated.Atomically find a document and replace it.TDocument
findOneAndReplace(Bson filter, TDocument replacement)
Deprecated.Atomically find a document and replace it.TDocument
findOneAndReplace(Bson filter, TDocument replacement, FindOneAndReplaceOptions options)
Deprecated.Atomically find a document and replace it.TDocument
findOneAndUpdate(ClientSession clientSession, Bson filter, java.util.List<? extends Bson> update)
Deprecated.Atomically find a document and update it.TDocument
findOneAndUpdate(ClientSession clientSession, Bson filter, java.util.List<? extends Bson> update, FindOneAndUpdateOptions options)
Deprecated.Atomically find a document and update it.TDocument
findOneAndUpdate(ClientSession clientSession, Bson filter, Bson update)
Deprecated.Atomically find a document and update it.TDocument
findOneAndUpdate(ClientSession clientSession, Bson filter, Bson update, FindOneAndUpdateOptions options)
Deprecated.Atomically find a document and update it.TDocument
findOneAndUpdate(Bson filter, java.util.List<? extends Bson> update)
Deprecated.Atomically find a document and update it.TDocument
findOneAndUpdate(Bson filter, java.util.List<? extends Bson> update, FindOneAndUpdateOptions options)
Deprecated.Atomically find a document and update it.TDocument
findOneAndUpdate(Bson filter, Bson update)
Deprecated.Atomically find a document and update it.TDocument
findOneAndUpdate(Bson filter, Bson update, FindOneAndUpdateOptions options)
Deprecated.Atomically find a document and update it.CodecRegistry
getCodecRegistry()
Deprecated.Get the codec registry for the MongoCollection.java.lang.Class<TDocument>
getDocumentClass()
Deprecated.Get the class of documents stored in this collection.MongoNamespace
getNamespace()
Deprecated.Gets the namespace of this collection.ReadConcern
getReadConcern()
Deprecated.Get the read concern for the MongoCollection.ReadPreference
getReadPreference()
Deprecated.Get the read preference for the MongoCollection.WriteConcern
getWriteConcern()
Deprecated.Get the write concern for the MongoCollection.void
insertMany(ClientSession clientSession, java.util.List<? extends TDocument> documents)
Deprecated.Inserts one or more documents.void
insertMany(ClientSession clientSession, java.util.List<? extends TDocument> documents, InsertManyOptions options)
Deprecated.Inserts one or more documents.void
insertMany(java.util.List<? extends TDocument> documents)
Deprecated.Inserts one or more documents.void
insertMany(java.util.List<? extends TDocument> documents, InsertManyOptions options)
Deprecated.Inserts one or more documents.void
insertOne(ClientSession clientSession, TDocument document)
Deprecated.Inserts the provided document.void
insertOne(ClientSession clientSession, TDocument document, InsertOneOptions options)
Deprecated.Inserts the provided document.void
insertOne(TDocument document)
Deprecated.Inserts the provided document.void
insertOne(TDocument document, InsertOneOptions options)
Deprecated.Inserts the provided document.ListIndexesIterable<Document>
listIndexes()
Deprecated.Get all the indexes in this collection.ListIndexesIterable<Document>
listIndexes(ClientSession clientSession)
Deprecated.Get all the indexes in this collection.<TResult> ListIndexesIterable<TResult>
listIndexes(ClientSession clientSession, java.lang.Class<TResult> resultClass)
Deprecated.Get all the indexes in this collection.<TResult> ListIndexesIterable<TResult>
listIndexes(java.lang.Class<TResult> resultClass)
Deprecated.Get all the indexes in this collection.MapReduceIterable<TDocument>
mapReduce(ClientSession clientSession, java.lang.String mapFunction, java.lang.String reduceFunction)
Deprecated.Aggregates documents according to the specified map-reduce function.<TResult> MapReduceIterable<TResult>
mapReduce(ClientSession clientSession, java.lang.String mapFunction, java.lang.String reduceFunction, java.lang.Class<TResult> resultClass)
Deprecated.Aggregates documents according to the specified map-reduce function.MapReduceIterable<TDocument>
mapReduce(java.lang.String mapFunction, java.lang.String reduceFunction)
Deprecated.Aggregates documents according to the specified map-reduce function.<TResult> MapReduceIterable<TResult>
mapReduce(java.lang.String mapFunction, java.lang.String reduceFunction, java.lang.Class<TResult> resultClass)
Deprecated.Aggregates documents according to the specified map-reduce function.void
renameCollection(ClientSession clientSession, MongoNamespace newCollectionNamespace)
Deprecated.Rename the collection with oldCollectionName to the newCollectionName.void
renameCollection(ClientSession clientSession, MongoNamespace newCollectionNamespace, RenameCollectionOptions renameCollectionOptions)
Deprecated.Rename the collection with oldCollectionName to the newCollectionName.void
renameCollection(MongoNamespace newCollectionNamespace)
Deprecated.Rename the collection with oldCollectionName to the newCollectionName.void
renameCollection(MongoNamespace newCollectionNamespace, RenameCollectionOptions renameCollectionOptions)
Deprecated.Rename the collection with oldCollectionName to the newCollectionName.UpdateResult
replaceOne(ClientSession clientSession, Bson filter, TDocument replacement)
Deprecated.Replace a document in the collection according to the specified arguments.UpdateResult
replaceOne(ClientSession clientSession, Bson filter, TDocument replacement, ReplaceOptions replaceOptions)
Deprecated.Replace a document in the collection according to the specified arguments.UpdateResult
replaceOne(ClientSession clientSession, Bson filter, TDocument replacement, UpdateOptions updateOptions)
Deprecated.UpdateResult
replaceOne(Bson filter, TDocument replacement)
Deprecated.Replace a document in the collection according to the specified arguments.UpdateResult
replaceOne(Bson filter, TDocument replacement, ReplaceOptions replaceOptions)
Deprecated.Replace a document in the collection according to the specified arguments.UpdateResult
replaceOne(Bson filter, TDocument replacement, UpdateOptions updateOptions)
Deprecated.usereplaceOne(Bson, Object, ReplaceOptions)
insteadUpdateResult
updateMany(ClientSession clientSession, Bson filter, java.util.List<? extends Bson> update)
Deprecated.Update all documents in the collection according to the specified arguments.UpdateResult
updateMany(ClientSession clientSession, Bson filter, java.util.List<? extends Bson> update, UpdateOptions updateOptions)
Deprecated.Update all documents in the collection according to the specified arguments.UpdateResult
updateMany(ClientSession clientSession, Bson filter, Bson update)
Deprecated.Update all documents in the collection according to the specified arguments.UpdateResult
updateMany(ClientSession clientSession, Bson filter, Bson update, UpdateOptions updateOptions)
Deprecated.Update all documents in the collection according to the specified arguments.UpdateResult
updateMany(Bson filter, java.util.List<? extends Bson> update)
Deprecated.Update all documents in the collection according to the specified arguments.UpdateResult
updateMany(Bson filter, java.util.List<? extends Bson> update, UpdateOptions updateOptions)
Deprecated.Update all documents in the collection according to the specified arguments.UpdateResult
updateMany(Bson filter, Bson update)
Deprecated.Update all documents in the collection according to the specified arguments.UpdateResult
updateMany(Bson filter, Bson update, UpdateOptions updateOptions)
Deprecated.Update all documents in the collection according to the specified arguments.UpdateResult
updateOne(ClientSession clientSession, Bson filter, java.util.List<? extends Bson> update)
Deprecated.Update a single document in the collection according to the specified arguments.UpdateResult
updateOne(ClientSession clientSession, Bson filter, java.util.List<? extends Bson> update, UpdateOptions updateOptions)
Deprecated.Update a single document in the collection according to the specified arguments.UpdateResult
updateOne(ClientSession clientSession, Bson filter, Bson update)
Deprecated.Update a single document in the collection according to the specified arguments.UpdateResult
updateOne(ClientSession clientSession, Bson filter, Bson update, UpdateOptions updateOptions)
Deprecated.Update a single document in the collection according to the specified arguments.UpdateResult
updateOne(Bson filter, java.util.List<? extends Bson> update)
Deprecated.Update a single document in the collection according to the specified arguments.UpdateResult
updateOne(Bson filter, java.util.List<? extends Bson> update, UpdateOptions updateOptions)
Deprecated.Update a single document in the collection according to the specified arguments.UpdateResult
updateOne(Bson filter, Bson update)
Deprecated.Update a single document in the collection according to the specified arguments.UpdateResult
updateOne(Bson filter, Bson update, UpdateOptions updateOptions)
Deprecated.Update a single document in the collection according to the specified arguments.ChangeStreamIterable<TDocument>
watch()
Deprecated.Creates a change stream for this collection.ChangeStreamIterable<TDocument>
watch(ClientSession clientSession)
Deprecated.Creates a change stream for this collection.<TResult> ChangeStreamIterable<TResult>
watch(ClientSession clientSession, java.lang.Class<TResult> resultClass)
Deprecated.Creates a change stream for this collection.ChangeStreamIterable<TDocument>
watch(ClientSession clientSession, java.util.List<? extends Bson> pipeline)
Deprecated.Creates a change stream for this collection.<TResult> ChangeStreamIterable<TResult>
watch(ClientSession clientSession, java.util.List<? extends Bson> pipeline, java.lang.Class<TResult> resultClass)
Deprecated.Creates a change stream for this collection.<TResult> ChangeStreamIterable<TResult>
watch(java.lang.Class<TResult> resultClass)
Deprecated.Creates a change stream for this collection.ChangeStreamIterable<TDocument>
watch(java.util.List<? extends Bson> pipeline)
Deprecated.Creates a change stream for this collection.<TResult> ChangeStreamIterable<TResult>
watch(java.util.List<? extends Bson> pipeline, java.lang.Class<TResult> resultClass)
Deprecated.Creates a change stream for this collection.MongoCollection<TDocument>
withCodecRegistry(CodecRegistry codecRegistry)
Deprecated.Create a new MongoCollection instance with a different codec registry.<NewTDocument>
MongoCollection<NewTDocument>withDocumentClass(java.lang.Class<NewTDocument> clazz)
Deprecated.Create a new MongoCollection instance with a different default class to cast any documents returned from the database into..MongoCollection<TDocument>
withReadConcern(ReadConcern readConcern)
Deprecated.Create a new MongoCollection instance with a different read concern.MongoCollection<TDocument>
withReadPreference(ReadPreference readPreference)
Deprecated.Create a new MongoCollection instance with a different read preference.MongoCollection<TDocument>
withWriteConcern(WriteConcern writeConcern)
Deprecated.Create a new MongoCollection instance with a different write concern.
-
-
-
Method Detail
-
getNamespace
MongoNamespace getNamespace()
Deprecated.Gets the namespace of this collection.- Returns:
- the namespace
-
getDocumentClass
java.lang.Class<TDocument> getDocumentClass()
Deprecated.Get the class of documents stored in this collection.- Returns:
- the class
-
getCodecRegistry
CodecRegistry getCodecRegistry()
Deprecated.Get the codec registry for the MongoCollection.- Returns:
- the
CodecRegistry
-
getReadPreference
ReadPreference getReadPreference()
Deprecated.Get the read preference for the MongoCollection.- Returns:
- the
ReadPreference
-
getWriteConcern
WriteConcern getWriteConcern()
Deprecated.Get the write concern for the MongoCollection.- Returns:
- the
WriteConcern
-
getReadConcern
ReadConcern getReadConcern()
Deprecated.Get the read concern for the MongoCollection.- Returns:
- the
ReadConcern
- Since:
- 3.2
-
withDocumentClass
<NewTDocument> MongoCollection<NewTDocument> withDocumentClass(java.lang.Class<NewTDocument> clazz)
Deprecated.Create a new MongoCollection instance with a different default class to cast any documents returned from the database into..- Type Parameters:
NewTDocument
- The type that the new collection will encode documents from and decode documents to- Parameters:
clazz
- the default class to cast any documents returned from the database into.- Returns:
- a new MongoCollection instance with the different default class
-
withCodecRegistry
MongoCollection<TDocument> withCodecRegistry(CodecRegistry codecRegistry)
Deprecated.Create a new MongoCollection instance with a different codec registry.- Parameters:
codecRegistry
- the newCodecRegistry
for the collection- Returns:
- a new MongoCollection instance with the different codec registry
-
withReadPreference
MongoCollection<TDocument> withReadPreference(ReadPreference readPreference)
Deprecated.Create a new MongoCollection instance with a different read preference.- Parameters:
readPreference
- the newReadPreference
for the collection- Returns:
- a new MongoCollection instance with the different readPreference
-
withWriteConcern
MongoCollection<TDocument> withWriteConcern(WriteConcern writeConcern)
Deprecated.Create a new MongoCollection instance with a different write concern.- Parameters:
writeConcern
- the newWriteConcern
for the collection- Returns:
- a new MongoCollection instance with the different writeConcern
-
withReadConcern
MongoCollection<TDocument> withReadConcern(ReadConcern readConcern)
Deprecated.Create a new MongoCollection instance with a different read concern.- Parameters:
readConcern
- the newReadConcern
for the collection- Returns:
- a new MongoCollection instance with the different ReadConcern
- Since:
- 3.2
-
count
@Deprecated long count()
Deprecated.usecountDocuments()
orestimatedDocumentCount()
insteadCounts the number of documents in the collection.- Returns:
- the number of documents in the collection
-
count
@Deprecated long count(Bson filter)
Deprecated.usecountDocuments(Bson)
insteadCounts the number of documents in the collection according to the given options.- Parameters:
filter
- the query filter- Returns:
- the number of documents in the collection
-
count
@Deprecated long count(Bson filter, CountOptions options)
Deprecated.usecountDocuments(Bson, CountOptions)
insteadCounts the number of documents in the collection according to the given options.- Parameters:
filter
- the query filteroptions
- the options describing the count- Returns:
- the number of documents in the collection
-
count
@Deprecated long count(ClientSession clientSession)
Deprecated.usecountDocuments(ClientSession)
insteadCounts the number of documents in the collection.- Parameters:
clientSession
- the client session with which to associate this operation- Returns:
- the number of documents in the collection
- Since:
- 3.6
-
count
@Deprecated long count(ClientSession clientSession, Bson filter)
Deprecated.usecountDocuments(ClientSession, Bson)
insteadCounts the number of documents in the collection according to the given options.- Parameters:
clientSession
- the client session with which to associate this operationfilter
- the query filter- Returns:
- the number of documents in the collection
- Since:
- 3.6
-
count
@Deprecated long count(ClientSession clientSession, Bson filter, CountOptions options)
Deprecated.Counts the number of documents in the collection according to the given options.- Parameters:
clientSession
- the client session with which to associate this operationfilter
- the query filteroptions
- the options describing the count- Returns:
- the number of documents in the collection
- Since:
- 3.6
-
countDocuments
long countDocuments()
Deprecated.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
-
countDocuments
long countDocuments(Bson filter)
Deprecated.Counts the number of documents in the collection according to the given options.Note: For a fast count of the total documents in a collection see
estimatedDocumentCount()
. 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
-
countDocuments
long countDocuments(Bson filter, CountOptions options)
Deprecated.Counts the number of documents in the collection according to the given options.Note: For a fast count of the total documents in a collection see
estimatedDocumentCount()
. When migrating fromcount()
tocountDocuments()
the following query operators must be replaced:+-------------+--------------------------------+ | Operator | Replacement | +=============+================================+ | $where | $expr | +-------------+--------------------------------+ | $near | $geoWithin with $center | +-------------+--------------------------------+ | $nearSphere | $geoWithin with $centerSphere | +-------------+--------------------------------+
- Parameters:
filter
- the query filteroptions
- the options describing the count- Returns:
- the number of documents in the collection
- Since:
- 3.8
-
countDocuments
long countDocuments(ClientSession clientSession)
Deprecated.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 | +-------------+--------------------------------+
- Parameters:
clientSession
- the client session with which to associate this operation- Returns:
- the number of documents in the collection
- Since:
- 3.8
-
countDocuments
long countDocuments(ClientSession clientSession, Bson filter)
Deprecated.Counts the number of documents in the collection according to the given options.Note: For a fast count of the total documents in a collection see
estimatedDocumentCount()
. When migrating fromcount()
tocountDocuments()
the following query operators must be replaced:+-------------+--------------------------------+ | Operator | Replacement | +=============+================================+ | $where | $expr | +-------------+--------------------------------+ | $near | $geoWithin with $center | +-------------+--------------------------------+ | $nearSphere | $geoWithin with $centerSphere | +-------------+--------------------------------+
- Parameters:
clientSession
- the client session with which to associate this operationfilter
- the query filter- Returns:
- the number of documents in the collection
- Since:
- 3.8
-
countDocuments
long countDocuments(ClientSession clientSession, Bson filter, CountOptions options)
Deprecated.Counts the number of documents in the collection according to the given options.Note: For a fast count of the total documents in a collection see
estimatedDocumentCount()
. When migrating fromcount()
tocountDocuments()
the following query operators must be replaced:+-------------+--------------------------------+ | Operator | Replacement | +=============+================================+ | $where | $expr | +-------------+--------------------------------+ | $near | $geoWithin with $center | +-------------+--------------------------------+ | $nearSphere | $geoWithin with $centerSphere | +-------------+--------------------------------+
- Parameters:
clientSession
- the client session with which to associate this operationfilter
- the query filteroptions
- the options describing the count- Returns:
- the number of documents in the collection
- Since:
- 3.8
-
estimatedDocumentCount
long estimatedDocumentCount()
Deprecated.Gets an estimate of the count of documents in a collection using collection metadata.- Returns:
- the number of documents in the collection
- Since:
- 3.8
-
estimatedDocumentCount
long estimatedDocumentCount(EstimatedDocumentCountOptions options)
Deprecated.Gets an estimate of the count of documents in a collection using collection metadata.- Parameters:
options
- the options describing the count- Returns:
- the number of documents in the collection
- Since:
- 3.8
-
distinct
<TResult> DistinctIterable<TResult> distinct(java.lang.String fieldName, java.lang.Class<TResult> resultClass)
Deprecated.Gets the distinct values of the specified field name.- Type Parameters:
TResult
- the target type of the iterable.- Parameters:
fieldName
- the field nameresultClass
- the class to cast any distinct items into.- Returns:
- an iterable of distinct values
-
distinct
<TResult> DistinctIterable<TResult> distinct(java.lang.String fieldName, Bson filter, java.lang.Class<TResult> resultClass)
Deprecated.Gets the distinct values of the specified field name.- Type Parameters:
TResult
- the target type of the iterable.- Parameters:
fieldName
- the field namefilter
- the query filterresultClass
- the class to cast any distinct items into.- Returns:
- an iterable of distinct values
-
distinct
<TResult> DistinctIterable<TResult> distinct(ClientSession clientSession, java.lang.String fieldName, java.lang.Class<TResult> resultClass)
Deprecated.Gets the distinct values of the specified field name.- Type Parameters:
TResult
- the target type of the iterable.- Parameters:
clientSession
- the client session with which to associate this operationfieldName
- the field nameresultClass
- the class to cast any distinct items into.- Returns:
- an iterable of distinct values
- Since:
- 3.6
-
distinct
<TResult> DistinctIterable<TResult> distinct(ClientSession clientSession, java.lang.String fieldName, Bson filter, java.lang.Class<TResult> resultClass)
Deprecated.Gets the distinct values of the specified field name.- Type Parameters:
TResult
- the target type of the iterable.- Parameters:
clientSession
- the client session with which to associate this operationfieldName
- the field namefilter
- the query filterresultClass
- the class to cast any distinct items into.- Returns:
- an iterable of distinct values
- Since:
- 3.6
-
find
FindIterable<TDocument> find()
Deprecated.Finds all documents in the collection.- Returns:
- the find iterable interface
-
find
<TResult> FindIterable<TResult> find(java.lang.Class<TResult> resultClass)
Deprecated.Finds 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
-
find
FindIterable<TDocument> find(Bson filter)
Deprecated.Finds all documents in the collection.- Parameters:
filter
- the query filter- Returns:
- the find iterable interface
-
find
<TResult> FindIterable<TResult> find(Bson filter, java.lang.Class<TResult> resultClass)
Deprecated.Finds all documents in the collection.- Type Parameters:
TResult
- the target document type of the iterable.- Parameters:
filter
- the query filterresultClass
- the class to decode each document into- Returns:
- the find iterable interface
-
find
FindIterable<TDocument> find(ClientSession clientSession)
Deprecated.Finds all documents in the collection.- Parameters:
clientSession
- the client session with which to associate this operation- Returns:
- the find iterable interface
- Since:
- 3.6
-
find
<TResult> FindIterable<TResult> find(ClientSession clientSession, java.lang.Class<TResult> resultClass)
Deprecated.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 operationresultClass
- the class to decode each document into- Returns:
- the find iterable interface
- Since:
- 3.6
-
find
FindIterable<TDocument> find(ClientSession clientSession, Bson filter)
Deprecated.Finds all documents in the collection.- Parameters:
clientSession
- the client session with which to associate this operationfilter
- the query filter- Returns:
- the find iterable interface
- Since:
- 3.6
-
find
<TResult> FindIterable<TResult> find(ClientSession clientSession, Bson filter, java.lang.Class<TResult> resultClass)
Deprecated.Finds all documents in the collection.- Type Parameters:
TResult
- the target document type of the iterable.- Parameters:
clientSession
- the client session with which to associate this operationfilter
- the query filterresultClass
- the class to decode each document into- Returns:
- the find iterable interface
- Since:
- 3.6
-
aggregate
AggregateIterable<TDocument> aggregate(java.util.List<? extends Bson> pipeline)
Deprecated.Aggregates documents according to the specified aggregation pipeline.- Parameters:
pipeline
- the aggregation pipeline- Returns:
- an iterable containing the result of the aggregation operation
-
aggregate
<TResult> AggregateIterable<TResult> aggregate(java.util.List<? extends Bson> pipeline, java.lang.Class<TResult> resultClass)
Deprecated.Aggregates documents according to the specified aggregation pipeline.- Type Parameters:
TResult
- the target document type of the iterable.- Parameters:
pipeline
- the aggregation pipelineresultClass
- the class to decode each document into- Returns:
- an iterable containing the result of the aggregation operation
-
aggregate
AggregateIterable<TDocument> aggregate(ClientSession clientSession, java.util.List<? extends Bson> pipeline)
Deprecated.Aggregates documents according to the specified aggregation pipeline.- Parameters:
clientSession
- the client session with which to associate this operationpipeline
- the aggregation pipeline- Returns:
- an iterable containing the result of the aggregation operation
- Since:
- 3.6
-
aggregate
<TResult> AggregateIterable<TResult> aggregate(ClientSession clientSession, java.util.List<? extends Bson> pipeline, java.lang.Class<TResult> resultClass)
Deprecated.Aggregates documents according to the specified aggregation pipeline.- Type Parameters:
TResult
- the target document type of the iterable.- Parameters:
clientSession
- the client session with which to associate this operationpipeline
- the aggregation pipelineresultClass
- the class to decode each document into- Returns:
- an iterable containing the result of the aggregation operation
- Since:
- 3.6
-
watch
ChangeStreamIterable<TDocument> watch()
Deprecated.Creates a change stream for this collection.- Returns:
- the change stream iterable
- Since:
- 3.6
-
watch
<TResult> ChangeStreamIterable<TResult> watch(java.lang.Class<TResult> resultClass)
Deprecated.Creates a change stream for this collection.- Type Parameters:
TResult
- the target document type of the iterable.- Parameters:
resultClass
- the class to decode each document into- Returns:
- the change stream iterable
- Since:
- 3.6
-
watch
ChangeStreamIterable<TDocument> watch(java.util.List<? extends Bson> pipeline)
Deprecated.Creates 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
-
watch
<TResult> ChangeStreamIterable<TResult> watch(java.util.List<? extends Bson> pipeline, java.lang.Class<TResult> resultClass)
Deprecated.Creates a change stream for this collection.- Type Parameters:
TResult
- the target document type of the iterable.- Parameters:
pipeline
- the aggregation pipeline to apply to the change streamresultClass
- the class to decode each document into- Returns:
- the change stream iterable
- Since:
- 3.6
-
watch
ChangeStreamIterable<TDocument> watch(ClientSession clientSession)
Deprecated.Creates 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
-
watch
<TResult> ChangeStreamIterable<TResult> watch(ClientSession clientSession, java.lang.Class<TResult> resultClass)
Deprecated.Creates a change stream for this collection.- Type Parameters:
TResult
- the target document type of the iterable.- Parameters:
clientSession
- the client session with which to associate this operationresultClass
- the class to decode each document into- Returns:
- the change stream iterable
- Since:
- 3.6
-
watch
ChangeStreamIterable<TDocument> watch(ClientSession clientSession, java.util.List<? extends Bson> pipeline)
Deprecated.Creates a change stream for this collection.- Parameters:
clientSession
- the client session with which to associate this operationpipeline
- the aggregation pipeline to apply to the change stream.- Returns:
- the change stream iterable
- Since:
- 3.6
-
watch
<TResult> ChangeStreamIterable<TResult> watch(ClientSession clientSession, java.util.List<? extends Bson> pipeline, java.lang.Class<TResult> resultClass)
Deprecated.Creates a change stream for this collection.- Type Parameters:
TResult
- the target document type of the iterable.- Parameters:
clientSession
- the client session with which to associate this operationpipeline
- the aggregation pipeline to apply to the change streamresultClass
- the class to decode each document into- Returns:
- the change stream iterable
- Since:
- 3.6
-
mapReduce
MapReduceIterable<TDocument> mapReduce(java.lang.String mapFunction, java.lang.String reduceFunction)
Deprecated.Aggregates documents according to the specified map-reduce function.- Parameters:
mapFunction
- A JavaScript function that associates or "maps" a value with a key and emits the key and value pair.reduceFunction
- A JavaScript function that "reduces" to a single object all the values associated with a particular key.- Returns:
- an iterable containing the result of the map-reduce operation
-
mapReduce
<TResult> MapReduceIterable<TResult> mapReduce(java.lang.String mapFunction, java.lang.String reduceFunction, java.lang.Class<TResult> resultClass)
Deprecated.Aggregates documents according to the specified map-reduce function.- Type Parameters:
TResult
- the target document type of the iterable.- Parameters:
mapFunction
- A JavaScript function that associates or "maps" a value with a key and emits the key and value pair.reduceFunction
- A JavaScript function that "reduces" to a single object all the values associated with a particular key.resultClass
- the class to decode each resulting document into.- Returns:
- an iterable containing the result of the map-reduce operation
-
mapReduce
MapReduceIterable<TDocument> mapReduce(ClientSession clientSession, java.lang.String mapFunction, java.lang.String reduceFunction)
Deprecated.Aggregates documents according to the specified map-reduce function.- Parameters:
clientSession
- the client session with which to associate this operationmapFunction
- A JavaScript function that associates or "maps" a value with a key and emits the key and value pair.reduceFunction
- A JavaScript function that "reduces" to a single object all the values associated with a particular key.- Returns:
- an iterable containing the result of the map-reduce operation
- Since:
- 3.6
-
mapReduce
<TResult> MapReduceIterable<TResult> mapReduce(ClientSession clientSession, java.lang.String mapFunction, java.lang.String reduceFunction, java.lang.Class<TResult> resultClass)
Deprecated.Aggregates documents according to the specified map-reduce function.- Type Parameters:
TResult
- the target document type of the iterable.- Parameters:
clientSession
- the client session with which to associate this operationmapFunction
- A JavaScript function that associates or "maps" a value with a key and emits the key and value pair.reduceFunction
- A JavaScript function that "reduces" to a single object all the values associated with a particular key.resultClass
- the class to decode each resulting document into.- Returns:
- an iterable containing the result of the map-reduce operation
- Since:
- 3.6
-
bulkWrite
BulkWriteResult bulkWrite(java.util.List<? extends WriteModel<? extends TDocument>> requests)
Deprecated.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
requests
contain anyUpdateManyModels
orDeleteManyModels
then 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 operationMongoException
- if there's an exception running the operation
-
bulkWrite
BulkWriteResult bulkWrite(java.util.List<? extends WriteModel<? extends TDocument>> requests, BulkWriteOptions options)
Deprecated.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
requests
contain anyUpdateManyModels
orDeleteManyModels
then the bulk operation will not support retryable writes.- Parameters:
requests
- the writes to executeoptions
- 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 operationMongoException
- if there's an exception running the operation
-
bulkWrite
BulkWriteResult bulkWrite(ClientSession clientSession, java.util.List<? extends WriteModel<? extends TDocument>> requests)
Deprecated.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
requests
contain anyUpdateManyModels
orDeleteManyModels
then the bulk operation will not support retryable writes.- Parameters:
clientSession
- the client session with which to associate this operationrequests
- the writes to execute- Returns:
- the result of the bulk write
- Throws:
MongoBulkWriteException
- if there's an exception in the bulk write operationMongoException
- if there's an exception running the operation- Since:
- 3.6
-
bulkWrite
BulkWriteResult bulkWrite(ClientSession clientSession, java.util.List<? extends WriteModel<? extends TDocument>> requests, BulkWriteOptions options)
Deprecated.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
requests
contain anyUpdateManyModels
orDeleteManyModels
then the bulk operation will not support retryable writes.- Parameters:
clientSession
- the client session with which to associate this operationrequests
- the writes to executeoptions
- the options to apply to the bulk write operation- Returns:
- the result of the bulk write
- Throws:
MongoBulkWriteException
- if there's an exception in the bulk write operationMongoException
- if there's an exception running the operation- Since:
- 3.6
-
insertOne
void insertOne(TDocument document)
Deprecated.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:
document
- the document to insert- Throws:
MongoWriteException
- if the write failed due to some specific write exceptionMongoWriteConcernException
- if the write failed due to being unable to fulfil the write concernMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure
-
insertOne
void insertOne(TDocument document, InsertOneOptions options)
Deprecated.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:
document
- the document to insertoptions
- the options to apply to the operation- Throws:
MongoWriteException
- if the write failed due to some specific write exceptionMongoWriteConcernException
- if the write failed due to being unable to fulfil the write concernMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure- Since:
- 3.2
-
insertOne
void insertOne(ClientSession clientSession, TDocument document)
Deprecated.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 operationdocument
- the document to insert- Throws:
MongoWriteException
- if the write failed due to some specific write exceptionMongoWriteConcernException
- if the write failed due to being unable to fulfil the write concernMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure- Since:
- 3.6
-
insertOne
void insertOne(ClientSession clientSession, TDocument document, InsertOneOptions options)
Deprecated.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 operationdocument
- the document to insertoptions
- the options to apply to the operation- Throws:
MongoWriteException
- if the write failed due to some specific write exceptionMongoWriteConcernException
- if the write failed due to being unable to fulfil the write concernMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure- Since:
- 3.6
-
insertMany
void insertMany(java.util.List<? extends TDocument> documents)
Deprecated.Inserts one or more documents. A call to this method is equivalent to a call to thebulkWrite
methodNote: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
- Parameters:
documents
- the documents to insert- Throws:
MongoBulkWriteException
- if there's an exception in the bulk write operationMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure- See Also:
bulkWrite(java.util.List<? extends com.mongodb.client.model.WriteModel<? extends TDocument>>)
-
insertMany
void insertMany(java.util.List<? extends TDocument> documents, InsertManyOptions options)
Deprecated.Inserts one or more documents. A call to this method is equivalent to a call to thebulkWrite
methodNote: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
- Parameters:
documents
- the documents to insertoptions
- the options to apply to the operation- Throws:
MongoBulkWriteException
- if there's an exception in the bulk write operationMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure
-
insertMany
void insertMany(ClientSession clientSession, java.util.List<? extends TDocument> documents)
Deprecated.Inserts one or more documents. A call to this method is equivalent to a call to thebulkWrite
methodNote: 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 operationdocuments
- the documents to insert- Throws:
MongoBulkWriteException
- if there's an exception in the bulk write operationMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure- Since:
- 3.6
- See Also:
bulkWrite(java.util.List<? extends com.mongodb.client.model.WriteModel<? extends TDocument>>)
-
insertMany
void insertMany(ClientSession clientSession, java.util.List<? extends TDocument> documents, InsertManyOptions options)
Deprecated.Inserts one or more documents. A call to this method is equivalent to a call to thebulkWrite
methodNote: 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 operationdocuments
- the documents to insertoptions
- the options to apply to the operation- Throws:
MongoBulkWriteException
- if there's an exception in the bulk write operationMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure- Since:
- 3.6
-
deleteOne
DeleteResult deleteOne(Bson filter)
Deprecated.Removes 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 the delete operation- Returns:
- the result of the remove one operation
- Throws:
MongoWriteException
- if the write failed due to some specific write exceptionMongoWriteConcernException
- if the write failed due to being unable to fulfil the write concernMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure
-
deleteOne
DeleteResult deleteOne(Bson filter, DeleteOptions options)
Deprecated.Removes 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 the delete operationoptions
- 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 exceptionMongoWriteConcernException
- if the write failed due to being unable to fulfil the write concernMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure- Since:
- 3.4
-
deleteOne
DeleteResult deleteOne(ClientSession clientSession, Bson filter)
Deprecated.Removes 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 operationfilter
- the query filter to apply the the delete operation- Returns:
- the result of the remove one operation
- Throws:
MongoWriteException
- if the write failed due to some specific write exceptionMongoWriteConcernException
- if the write failed due to being unable to fulfil the write concernMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure- Since:
- 3.6
-
deleteOne
DeleteResult deleteOne(ClientSession clientSession, Bson filter, DeleteOptions options)
Deprecated.Removes 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 operationfilter
- the query filter to apply the the delete operationoptions
- 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 exceptionMongoWriteConcernException
- if the write failed due to being unable to fulfil the write concernMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure- Since:
- 3.6
-
deleteMany
DeleteResult deleteMany(Bson filter)
Deprecated.Removes all documents from the collection that match the given query filter. If no documents match, the collection is not modified.- Parameters:
filter
- the query filter to apply the the delete operation- Returns:
- the result of the remove many operation
- Throws:
MongoWriteException
- if the write failed due to some specific write exceptionMongoWriteConcernException
- if the write failed due to being unable to fulfil the write concernMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure
-
deleteMany
DeleteResult deleteMany(Bson filter, DeleteOptions options)
Deprecated.Removes all documents from the collection that match the given query filter. If no documents match, the collection is not modified.- Parameters:
filter
- the query filter to apply the the delete operationoptions
- the options to apply to the delete operation- Returns:
- the result of the remove many operation
- Throws:
MongoWriteException
- if the write failed due to some specific write exceptionMongoWriteConcernException
- if the write failed due to being unable to fulfil the write concernMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure- Since:
- 3.4
-
deleteMany
DeleteResult deleteMany(ClientSession clientSession, Bson filter)
Deprecated.Removes all documents from the collection that match the given query filter. If no documents match, the collection is not modified.- Parameters:
clientSession
- the client session with which to associate this operationfilter
- the query filter to apply the the delete operation- Returns:
- the result of the remove many operation
- Throws:
MongoWriteException
- if the write failed due to some specific write exceptionMongoWriteConcernException
- if the write failed due to being unable to fulfil the write concernMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure- Since:
- 3.6
-
deleteMany
DeleteResult deleteMany(ClientSession clientSession, Bson filter, DeleteOptions options)
Deprecated.Removes all documents from the collection that match the given query filter. If no documents match, the collection is not modified.- Parameters:
clientSession
- the client session with which to associate this operationfilter
- the query filter to apply the the delete operationoptions
- the options to apply to the delete operation- Returns:
- the result of the remove many operation
- Throws:
MongoWriteException
- if the write failed due to some specific write exceptionMongoWriteConcernException
- if the write failed due to being unable to fulfil the write concernMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure- Since:
- 3.6
-
replaceOne
UpdateResult replaceOne(Bson filter, TDocument replacement)
Deprecated.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(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 the replace operationreplacement
- the replacement document- Returns:
- the result of the replace one operation
- Throws:
MongoWriteException
- if the write failed due to some specific write exceptionMongoWriteConcernException
- if the write failed due to being unable to fulfil the write concernMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure
-
replaceOne
@Deprecated UpdateResult replaceOne(Bson filter, TDocument replacement, UpdateOptions updateOptions)
Deprecated.usereplaceOne(Bson, Object, ReplaceOptions)
insteadReplace 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 the replace operationreplacement
- the replacement documentupdateOptions
- 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 exceptionMongoWriteConcernException
- if the write failed due to being unable to fulfil the write concernMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure
-
replaceOne
UpdateResult replaceOne(Bson filter, TDocument replacement, ReplaceOptions replaceOptions)
Deprecated.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(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 the replace operationreplacement
- the replacement documentreplaceOptions
- 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 exceptionMongoWriteConcernException
- if the write failed due to being unable to fulfil the write concernMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure- Since:
- 3.7
-
replaceOne
UpdateResult replaceOne(ClientSession clientSession, Bson filter, TDocument replacement)
Deprecated.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)
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 operationfilter
- the query filter to apply the the replace operationreplacement
- the replacement document- Returns:
- the result of the replace one operation
- Throws:
MongoWriteException
- if the write failed due to some specific write exceptionMongoWriteConcernException
- if the write failed due to being unable to fulfil the write concernMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure- Since:
- 3.6
-
replaceOne
@Deprecated UpdateResult replaceOne(ClientSession clientSession, Bson filter, TDocument replacement, UpdateOptions updateOptions)
Deprecated.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 operationfilter
- the query filter to apply the the replace operationreplacement
- the replacement documentupdateOptions
- 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 exceptionMongoWriteConcernException
- if the write failed due to being unable to fulfil the write concernMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure- Since:
- 3.6
-
replaceOne
UpdateResult replaceOne(ClientSession clientSession, Bson filter, TDocument replacement, ReplaceOptions replaceOptions)
Deprecated.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 operationfilter
- the query filter to apply the the replace operationreplacement
- the replacement documentreplaceOptions
- 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 exceptionMongoWriteConcernException
- if the write failed due to being unable to fulfil the write concernMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure- Since:
- 3.7
-
updateOne
UpdateResult updateOne(Bson filter, Bson update)
Deprecated.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(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 exceptionMongoWriteConcernException
- if the write failed due to being unable to fulfil the write concernMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure- See Also:
replaceOne(Bson, Object)
-
updateOne
UpdateResult updateOne(Bson filter, Bson update, UpdateOptions updateOptions)
Deprecated.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(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 exceptionMongoWriteConcernException
- if the write failed due to being unable to fulfil the write concernMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure- See Also:
replaceOne(Bson, Object, ReplaceOptions)
-
updateOne
UpdateResult updateOne(ClientSession clientSession, Bson filter, Bson update)
Deprecated.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)
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 operationfilter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include at least one update operator.- Returns:
- the result of the update one operation
- Throws:
MongoWriteException
- if the write failed due to some specific write exceptionMongoWriteConcernException
- if the write failed due to being unable to fulfil the write concernMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure- Since:
- 3.6
- See Also:
replaceOne(ClientSession, Bson, Object)
-
updateOne
UpdateResult updateOne(ClientSession clientSession, Bson filter, Bson update, UpdateOptions updateOptions)
Deprecated.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 operationfilter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include 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 exceptionMongoWriteConcernException
- if the write failed due to being unable to fulfil the write concernMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure- Since:
- 3.6
- See Also:
replaceOne(ClientSession, Bson, Object, ReplaceOptions)
-
updateOne
UpdateResult updateOne(Bson filter, java.util.List<? extends Bson> update)
Deprecated.Update a single document in the collection according to the specified arguments.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
- Parameters:
filter
- a document describing the query filter, which may not be null.update
- a pipeline describing the update, which may not be null.- Returns:
- the result of the update one operation
- Throws:
MongoWriteException
- if the write failed due some other failure specific to the update commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failure- Since:
- 3.11
-
updateOne
UpdateResult updateOne(Bson filter, java.util.List<? extends Bson> update, UpdateOptions updateOptions)
Deprecated.Update a single document in the collection according to the specified arguments.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
- Parameters:
filter
- a document describing the query filter, which may not be null.update
- a pipeline describing the update, which may not be null.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 commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failure- Since:
- 3.11
-
updateOne
UpdateResult updateOne(ClientSession clientSession, Bson filter, java.util.List<? extends Bson> update)
Deprecated.Update a single document in the collection according to the specified arguments.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
- Parameters:
clientSession
- the client session with which to associate this operationfilter
- a document describing the query filter, which may not be null.update
- a pipeline describing the update, which may not be null.- Returns:
- the result of the update one operation
- Throws:
MongoWriteException
- if the write failed due some other failure specific to the update commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failure- Since:
- 3.11
-
updateOne
UpdateResult updateOne(ClientSession clientSession, Bson filter, java.util.List<? extends Bson> update, UpdateOptions updateOptions)
Deprecated.Update a single document in the collection according to the specified arguments.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
- Parameters:
clientSession
- the client session with which to associate this operationfilter
- a document describing the query filter, which may not be null.update
- a pipeline describing the update, which may not be null.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 commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failure- Since:
- 3.11
-
updateMany
UpdateResult updateMany(Bson filter, Bson update)
Deprecated.Update all documents in the collection according to the specified arguments.- Parameters:
filter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include only update operators.- Returns:
- the result of the update many operation
- Throws:
MongoWriteException
- if the write failed due to some specific write exceptionMongoWriteConcernException
- if the write failed due to being unable to fulfil the write concernMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure
-
updateMany
UpdateResult updateMany(Bson filter, Bson update, UpdateOptions updateOptions)
Deprecated.Update all documents in the collection according to the specified arguments.- Parameters:
filter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include only update operators.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 exceptionMongoWriteConcernException
- if the write failed due to being unable to fulfil the write concernMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure
-
updateMany
UpdateResult updateMany(ClientSession clientSession, Bson filter, Bson update)
Deprecated.Update all documents in the collection according to the specified arguments.- Parameters:
clientSession
- the client session with which to associate this operationfilter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include only update operators.- Returns:
- the result of the update many operation
- Throws:
MongoWriteException
- if the write failed due to some specific write exceptionMongoWriteConcernException
- if the write failed due to being unable to fulfil the write concernMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure- Since:
- 3.6
-
updateMany
UpdateResult updateMany(ClientSession clientSession, Bson filter, Bson update, UpdateOptions updateOptions)
Deprecated.Update all documents in the collection according to the specified arguments.- Parameters:
clientSession
- the client session with which to associate this operationfilter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include only update operators.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 exceptionMongoWriteConcernException
- if the write failed due to being unable to fulfil the write concernMongoCommandException
- if the write failed due to a specific command exceptionMongoException
- if the write failed due some other failure- Since:
- 3.6
-
updateMany
UpdateResult updateMany(Bson filter, java.util.List<? extends Bson> update)
Deprecated.Update all documents in the collection according to the specified arguments.- Parameters:
filter
- a document describing the query filter, which may not be null.update
- a pipeline describing the update, which may not be null.- Returns:
- the result of the update many operation
- Throws:
MongoWriteException
- if the write failed due some other failure specific to the update commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failure- Since:
- 3.11
-
updateMany
UpdateResult updateMany(Bson filter, java.util.List<? extends Bson> update, UpdateOptions updateOptions)
Deprecated.Update all documents in the collection according to the specified arguments.- Parameters:
filter
- a document describing the query filter, which may not be null.update
- a pipeline describing the update, which may not be null.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 commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failure- Since:
- 3.11
-
updateMany
UpdateResult updateMany(ClientSession clientSession, Bson filter, java.util.List<? extends Bson> update)
Deprecated.Update all documents in the collection according to the specified arguments.- Parameters:
clientSession
- the client session with which to associate this operationfilter
- a document describing the query filter, which may not be null.update
- a pipeline describing the update, which may not be null.- Returns:
- the result of the update many operation
- Throws:
MongoWriteException
- if the write failed due some other failure specific to the update commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failure- Since:
- 3.11
-
updateMany
UpdateResult updateMany(ClientSession clientSession, Bson filter, java.util.List<? extends Bson> update, UpdateOptions updateOptions)
Deprecated.Update all documents in the collection according to the specified arguments.- Parameters:
clientSession
- the client session with which to associate this operationfilter
- a document describing the query filter, which may not be null.update
- a pipeline describing the update, which may not be null.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 commandMongoWriteConcernException
- if the write failed due being unable to fulfil the write concernMongoException
- if the write failed due some other failure- Since:
- 3.11
-
findOneAndDelete
@Nullable TDocument findOneAndDelete(Bson filter)
Deprecated.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:
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
-
findOneAndDelete
@Nullable TDocument findOneAndDelete(Bson filter, FindOneAndDeleteOptions options)
Deprecated.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:
filter
- the query filter to find the document withoptions
- 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
-
findOneAndDelete
@Nullable TDocument findOneAndDelete(ClientSession clientSession, Bson filter)
Deprecated.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 operationfilter
- 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
-
findOneAndDelete
@Nullable TDocument findOneAndDelete(ClientSession clientSession, Bson filter, FindOneAndDeleteOptions options)
Deprecated.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 operationfilter
- the query filter to find the document withoptions
- 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
-
findOneAndReplace
@Nullable TDocument findOneAndReplace(Bson filter, TDocument replacement)
Deprecated.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)
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 the replace operationreplacement
- the replacement document- Returns:
- the document that was replaced. Depending on the value of the
returnOriginal
property, this will either be the document as it was before the update or as it is after the update. If no documents matched the query filter, then null will be returned
-
findOneAndReplace
@Nullable TDocument findOneAndReplace(Bson filter, TDocument replacement, FindOneAndReplaceOptions options)
Deprecated.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 the replace operationreplacement
- the replacement documentoptions
- the options to apply to the operation- Returns:
- the document that was replaced. Depending on the value of the
returnOriginal
property, this will either be the document as it was before the update or as it is after the update. If no documents matched the query filter, then null will be returned
-
findOneAndReplace
@Nullable TDocument findOneAndReplace(ClientSession clientSession, Bson filter, TDocument replacement)
Deprecated.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 operationfilter
- the query filter to apply the the replace operationreplacement
- the replacement document- Returns:
- the document that was replaced. Depending on the value of the
returnOriginal
property, this will either be the document as it was before the update or as it is after the update. If no documents matched the query filter, then null will be returned - Since:
- 3.6
-
findOneAndReplace
@Nullable TDocument findOneAndReplace(ClientSession clientSession, Bson filter, TDocument replacement, FindOneAndReplaceOptions options)
Deprecated.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 operationfilter
- the query filter to apply the the replace operationreplacement
- the replacement documentoptions
- the options to apply to the operation- Returns:
- the document that was replaced. Depending on the value of the
returnOriginal
property, this will either be the document as it was before the update or as it is after the update. If no documents matched the query filter, then null will be returned - Since:
- 3.6
-
findOneAndUpdate
@Nullable TDocument findOneAndUpdate(Bson filter, Bson update)
Deprecated.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(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:
findOneAndReplace(Bson, Object)
-
findOneAndUpdate
@Nullable TDocument findOneAndUpdate(Bson filter, Bson update, FindOneAndUpdateOptions options)
Deprecated.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(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
returnOriginal
property, this will either be the document as it was before the update or as it is after the update. If no documents matched the query filter, then null will be returned - See Also:
findOneAndReplace(Bson, Object, FindOneAndReplaceOptions)
-
findOneAndUpdate
@Nullable TDocument findOneAndUpdate(ClientSession clientSession, Bson filter, Bson update)
Deprecated.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)
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 operationfilter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include 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:
findOneAndReplace(ClientSession, Bson, Object)
-
findOneAndUpdate
@Nullable TDocument findOneAndUpdate(ClientSession clientSession, Bson filter, Bson update, FindOneAndUpdateOptions options)
Deprecated.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 operationfilter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include 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
returnOriginal
property, this will either be the document as it was before the update or as it is after the update. If no documents matched the query filter, then null will be returned - Since:
- 3.6
- See Also:
findOneAndReplace(ClientSession, Bson, Object, FindOneAndReplaceOptions)
-
findOneAndUpdate
@Nullable TDocument findOneAndUpdate(Bson filter, java.util.List<? extends Bson> update)
Deprecated.Atomically find a document and update it.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
- Parameters:
filter
- a document describing the query filter, which may not be null.update
- a pipeline describing the update, which may not be null.- Returns:
- 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
-
findOneAndUpdate
@Nullable TDocument findOneAndUpdate(Bson filter, java.util.List<? extends Bson> update, FindOneAndUpdateOptions options)
Deprecated.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
returnOriginal
property, this will either be the document as it was before the update or as it is after the update. If no documents matched the query filter, then null will be returned - Since:
- 3.11
-
findOneAndUpdate
@Nullable TDocument findOneAndUpdate(ClientSession clientSession, Bson filter, java.util.List<? extends Bson> update)
Deprecated.Atomically find a document and update it.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
- Parameters:
clientSession
- the client session with which to associate this operationfilter
- a document describing the query filter, which may not be null.update
- a pipeline describing the update, which may not be null.- Returns:
- 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
-
findOneAndUpdate
@Nullable TDocument findOneAndUpdate(ClientSession clientSession, Bson filter, java.util.List<? extends Bson> update, FindOneAndUpdateOptions options)
Deprecated.Atomically find a document and update it.Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
- Parameters:
clientSession
- the client session with which to associate this operationfilter
- a document describing the query filter, which may not be null.update
- a pipeline describing the update, which may not be null.options
- the options to apply to the operation- Returns:
- the document that was updated. Depending on the value of the
returnOriginal
property, this will either be the document as it was before the update or as it is after the update. If no documents matched the query filter, then null will be returned - Since:
- 3.11
-
drop
void drop()
Deprecated.Drops this collection from the Database.
-
drop
void drop(ClientSession clientSession)
Deprecated.Drops this collection from the Database.- Parameters:
clientSession
- the client session with which to associate this operation- Since:
- 3.6
-
createIndex
java.lang.String createIndex(Bson keys)
Deprecated.Create an index with the given keys.- Parameters:
keys
- an object describing the index key(s), which may not be null.- Returns:
- the index name
-
createIndex
java.lang.String createIndex(Bson keys, IndexOptions indexOptions)
Deprecated.Create 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
-
createIndex
java.lang.String createIndex(ClientSession clientSession, Bson keys)
Deprecated.Create an index with the given keys.- Parameters:
clientSession
- the client session with which to associate this operationkeys
- an object describing the index key(s), which may not be null.- Returns:
- the index name
- Since:
- 3.6
-
createIndex
java.lang.String createIndex(ClientSession clientSession, Bson keys, IndexOptions indexOptions)
Deprecated.Create an index with the given keys and options.- Parameters:
clientSession
- the client session with which to associate this operationkeys
- an object describing the index key(s), which may not be null.indexOptions
- the options for the index- Returns:
- the index name
- Since:
- 3.6
-
createIndexes
java.util.List<java.lang.String> createIndexes(java.util.List<IndexModel> indexes)
Deprecated.Create multiple indexes.- Parameters:
indexes
- the list of indexes- Returns:
- the list of index names
-
createIndexes
java.util.List<java.lang.String> createIndexes(java.util.List<IndexModel> indexes, CreateIndexOptions createIndexOptions)
Deprecated.Create multiple indexes.- Parameters:
indexes
- the list of indexescreateIndexOptions
- options to use when creating indexes- Returns:
- the list of index names
- Since:
- 3.6
-
createIndexes
java.util.List<java.lang.String> createIndexes(ClientSession clientSession, java.util.List<IndexModel> indexes)
Deprecated.Create multiple indexes.- Parameters:
clientSession
- the client session with which to associate this operationindexes
- the list of indexes- Returns:
- the list of index names
- Since:
- 3.6
-
createIndexes
java.util.List<java.lang.String> createIndexes(ClientSession clientSession, java.util.List<IndexModel> indexes, CreateIndexOptions createIndexOptions)
Deprecated.Create multiple indexes.- Parameters:
clientSession
- the client session with which to associate this operationindexes
- the list of indexescreateIndexOptions
- options to use when creating indexes- Returns:
- the list of index names
- Since:
- 3.6
-
listIndexes
ListIndexesIterable<Document> listIndexes()
Deprecated.Get all the indexes in this collection.- Returns:
- the list indexes iterable interface
-
listIndexes
<TResult> ListIndexesIterable<TResult> listIndexes(java.lang.Class<TResult> resultClass)
Deprecated.Get 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
-
listIndexes
ListIndexesIterable<Document> listIndexes(ClientSession clientSession)
Deprecated.Get 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
-
listIndexes
<TResult> ListIndexesIterable<TResult> listIndexes(ClientSession clientSession, java.lang.Class<TResult> resultClass)
Deprecated.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 operationresultClass
- the class to decode each document into- Returns:
- the list indexes iterable interface
- Since:
- 3.6
-
dropIndex
void dropIndex(java.lang.String indexName)
Deprecated.Drops the index given its name.- Parameters:
indexName
- the name of the index to remove
-
dropIndex
void dropIndex(java.lang.String indexName, DropIndexOptions dropIndexOptions)
Deprecated.Drops the index given its name.- Parameters:
indexName
- the name of the index to removedropIndexOptions
- the options to use when dropping indexes- Since:
- 3.6
-
dropIndex
void dropIndex(Bson keys)
Deprecated.Drops the index given the keys used to create it.- Parameters:
keys
- the keys of the index to remove
-
dropIndex
void dropIndex(Bson keys, DropIndexOptions dropIndexOptions)
Deprecated.Drops the index given the keys used to create it.- Parameters:
keys
- the keys of the index to removedropIndexOptions
- the options to use when dropping indexes- Since:
- 3.6
-
dropIndex
void dropIndex(ClientSession clientSession, java.lang.String indexName)
Deprecated.Drops the index given its name.- Parameters:
clientSession
- the client session with which to associate this operationindexName
- the name of the index to remove- Since:
- 3.6
-
dropIndex
void dropIndex(ClientSession clientSession, Bson keys)
Deprecated.Drops the index given the keys used to create it.- Parameters:
clientSession
- the client session with which to associate this operationkeys
- the keys of the index to remove- Since:
- 3.6
-
dropIndex
void dropIndex(ClientSession clientSession, java.lang.String indexName, DropIndexOptions dropIndexOptions)
Deprecated.Drops the index given its name.- Parameters:
clientSession
- the client session with which to associate this operationindexName
- the name of the index to removedropIndexOptions
- the options to use when dropping indexes- Since:
- 3.6
-
dropIndex
void dropIndex(ClientSession clientSession, Bson keys, DropIndexOptions dropIndexOptions)
Deprecated.Drops the index given the keys used to create it.- Parameters:
clientSession
- the client session with which to associate this operationkeys
- the keys of the index to removedropIndexOptions
- the options to use when dropping indexes- Since:
- 3.6
-
dropIndexes
void dropIndexes()
Deprecated.Drop all the indexes on this collection, except for the default on _id.
-
dropIndexes
void dropIndexes(ClientSession clientSession)
Deprecated.Drop 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
-
dropIndexes
void dropIndexes(DropIndexOptions dropIndexOptions)
Deprecated.Drop all the indexes on this collection, except for the default on _id.- Parameters:
dropIndexOptions
- the options to use when dropping indexes- Since:
- 3.6
-
dropIndexes
void dropIndexes(ClientSession clientSession, DropIndexOptions dropIndexOptions)
Deprecated.Drop all the indexes on this collection, except for the default on _id.- Parameters:
clientSession
- the client session with which to associate this operationdropIndexOptions
- the options to use when dropping indexes- Since:
- 3.6
-
renameCollection
void renameCollection(MongoNamespace newCollectionNamespace)
Deprecated.Rename 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
-
renameCollection
void renameCollection(MongoNamespace newCollectionNamespace, RenameCollectionOptions renameCollectionOptions)
Deprecated.Rename the collection with oldCollectionName to the newCollectionName.- Parameters:
newCollectionNamespace
- the name the collection will be renamed torenameCollectionOptions
- 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
-
renameCollection
void renameCollection(ClientSession clientSession, MongoNamespace newCollectionNamespace)
Deprecated.Rename the collection with oldCollectionName to the newCollectionName.- Parameters:
clientSession
- the client session with which to associate this operationnewCollectionNamespace
- the namespace the collection will be renamed to- 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
-
renameCollection
void renameCollection(ClientSession clientSession, MongoNamespace newCollectionNamespace, RenameCollectionOptions renameCollectionOptions)
Deprecated.Rename the collection with oldCollectionName to the newCollectionName.- Parameters:
clientSession
- the client session with which to associate this operationnewCollectionNamespace
- the name the collection will be renamed torenameCollectionOptions
- 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
-
-