Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
com.mongodb.reactivestreams.client

Interface MongoCollection<TDocument>

  • Type Parameters:
    TDocument - The type that this collection will encode documents from and decode documents to.


    @ThreadSafe
    public interface MongoCollection<TDocument>
    The MongoCollection interface.

    Note: Additions to this interface will not be considered to break binary compatibility.

    Since:
    1.0
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      AggregatePublisher<org.bson.Document> aggregate(List<? extends org.bson.conversions.Bson> pipeline)
      Aggregates documents according to the specified aggregation pipeline.
      <TResult> AggregatePublisher<TResult> aggregate(List<? extends org.bson.conversions.Bson> pipeline, Class<TResult> clazz)
      Aggregates documents according to the specified aggregation pipeline.
      org.reactivestreams.Publisher<com.mongodb.bulk.BulkWriteResult> bulkWrite(List<? extends com.mongodb.client.model.WriteModel<? extends TDocument>> requests)
      Executes a mix of inserts, updates, replaces, and deletes.
      org.reactivestreams.Publisher<com.mongodb.bulk.BulkWriteResult> bulkWrite(List<? extends com.mongodb.client.model.WriteModel<? extends TDocument>> requests, com.mongodb.client.model.BulkWriteOptions options)
      Executes a mix of inserts, updates, replaces, and deletes.
      org.reactivestreams.Publisher<Long> count()
      Counts the number of documents in the collection.
      org.reactivestreams.Publisher<Long> count(org.bson.conversions.Bson filter)
      Counts the number of documents in the collection according to the given options.
      org.reactivestreams.Publisher<Long> count(org.bson.conversions.Bson filter, com.mongodb.client.model.CountOptions options)
      Counts the number of documents in the collection according to the given options.
      org.reactivestreams.Publisher<String> createIndex(org.bson.conversions.Bson key)
      Creates an index.
      org.reactivestreams.Publisher<String> createIndex(org.bson.conversions.Bson key, com.mongodb.client.model.IndexOptions options)
      Creates an index.
      org.reactivestreams.Publisher<String> createIndexes(List<com.mongodb.client.model.IndexModel> indexes)
      Create multiple indexes.
      org.reactivestreams.Publisher<com.mongodb.client.result.DeleteResult> deleteMany(org.bson.conversions.Bson filter)
      Removes all documents from the collection that match the given query filter.
      org.reactivestreams.Publisher<com.mongodb.client.result.DeleteResult> deleteMany(org.bson.conversions.Bson filter, com.mongodb.client.model.DeleteOptions options)
      Removes all documents from the collection that match the given query filter.
      org.reactivestreams.Publisher<com.mongodb.client.result.DeleteResult> deleteOne(org.bson.conversions.Bson filter)
      Removes at most one document from the collection that matches the given filter.
      org.reactivestreams.Publisher<com.mongodb.client.result.DeleteResult> deleteOne(org.bson.conversions.Bson filter, com.mongodb.client.model.DeleteOptions options)
      Removes at most one document from the collection that matches the given filter.
      <TResult> DistinctPublisher<TResult> distinct(String fieldName, org.bson.conversions.Bson filter, Class<TResult> resultClass)
      Gets the distinct values of the specified field name.
      <TResult> DistinctPublisher<TResult> distinct(String fieldName, Class<TResult> resultClass)
      Gets the distinct values of the specified field name.
      org.reactivestreams.Publisher<Success> drop()
      Drops this collection from the Database.
      org.reactivestreams.Publisher<Success> dropIndex(org.bson.conversions.Bson keys)
      Drops the index given the keys used to create it.
      org.reactivestreams.Publisher<Success> dropIndex(String indexName)
      Drops the given index.
      org.reactivestreams.Publisher<Success> dropIndexes()
      Drop all the indexes on this collection, except for the default on _id.
      FindPublisher<TDocument> find()
      Finds all documents in the collection.
      FindPublisher<TDocument> find(org.bson.conversions.Bson filter)
      Finds all documents in the collection.
      <TResult> FindPublisher<TResult> find(org.bson.conversions.Bson filter, Class<TResult> clazz)
      Finds all documents in the collection.
      <TResult> FindPublisher<TResult> find(Class<TResult> clazz)
      Finds all documents in the collection.
      org.reactivestreams.Publisher<TDocument> findOneAndDelete(org.bson.conversions.Bson filter)
      Atomically find a document and remove it.
      org.reactivestreams.Publisher<TDocument> findOneAndDelete(org.bson.conversions.Bson filter, com.mongodb.client.model.FindOneAndDeleteOptions options)
      Atomically find a document and remove it.
      org.reactivestreams.Publisher<TDocument> findOneAndReplace(org.bson.conversions.Bson filter, TDocument replacement)
      Atomically find a document and replace it.
      org.reactivestreams.Publisher<TDocument> findOneAndReplace(org.bson.conversions.Bson filter, TDocument replacement, com.mongodb.client.model.FindOneAndReplaceOptions options)
      Atomically find a document and replace it.
      org.reactivestreams.Publisher<TDocument> findOneAndUpdate(org.bson.conversions.Bson filter, org.bson.conversions.Bson update)
      Atomically find a document and update it.
      org.reactivestreams.Publisher<TDocument> findOneAndUpdate(org.bson.conversions.Bson filter, org.bson.conversions.Bson update, com.mongodb.client.model.FindOneAndUpdateOptions options)
      Atomically find a document and update it.
      org.bson.codecs.configuration.CodecRegistry getCodecRegistry()
      Get the codec registry for the MongoCollection.
      Class<TDocument> getDocumentClass()
      Get the class of documents stored in this collection.
      com.mongodb.MongoNamespace getNamespace()
      Gets the namespace of this collection.
      com.mongodb.ReadConcern getReadConcern()
      Get the read concern for the MongoCollection.
      com.mongodb.ReadPreference getReadPreference()
      Get the read preference for the MongoCollection.
      com.mongodb.WriteConcern getWriteConcern()
      Get the write concern for the MongoCollection.
      org.reactivestreams.Publisher<Success> insertMany(List<? extends TDocument> documents)
      Inserts a batch of documents.
      org.reactivestreams.Publisher<Success> insertMany(List<? extends TDocument> documents, com.mongodb.client.model.InsertManyOptions options)
      Inserts a batch of documents.
      org.reactivestreams.Publisher<Success> insertOne(TDocument document)
      Inserts the provided document.
      org.reactivestreams.Publisher<Success> insertOne(TDocument document, com.mongodb.client.model.InsertOneOptions options)
      Inserts the provided document.
      ListIndexesPublisher<org.bson.Document> listIndexes()
      Get all the indexes in this collection.
      <TResult> ListIndexesPublisher<TResult> listIndexes(Class<TResult> clazz)
      Get all the indexes in this collection.
      MapReducePublisher<org.bson.Document> mapReduce(String mapFunction, String reduceFunction)
      Aggregates documents according to the specified map-reduce function.
      <TResult> MapReducePublisher<TResult> mapReduce(String mapFunction, String reduceFunction, Class<TResult> clazz)
      Aggregates documents according to the specified map-reduce function.
      org.reactivestreams.Publisher<Success> renameCollection(com.mongodb.MongoNamespace newCollectionNamespace)
      Rename the collection with oldCollectionName to the newCollectionName.
      org.reactivestreams.Publisher<Success> renameCollection(com.mongodb.MongoNamespace newCollectionNamespace, com.mongodb.client.model.RenameCollectionOptions options)
      Rename the collection with oldCollectionName to the newCollectionName.
      org.reactivestreams.Publisher<com.mongodb.client.result.UpdateResult> replaceOne(org.bson.conversions.Bson filter, TDocument replacement)
      Replace a document in the collection according to the specified arguments.
      org.reactivestreams.Publisher<com.mongodb.client.result.UpdateResult> replaceOne(org.bson.conversions.Bson filter, TDocument replacement, com.mongodb.client.model.UpdateOptions options)
      Replace a document in the collection according to the specified arguments.
      org.reactivestreams.Publisher<com.mongodb.client.result.UpdateResult> updateMany(org.bson.conversions.Bson filter, org.bson.conversions.Bson update)
      Update all documents in the collection according to the specified arguments.
      org.reactivestreams.Publisher<com.mongodb.client.result.UpdateResult> updateMany(org.bson.conversions.Bson filter, org.bson.conversions.Bson update, com.mongodb.client.model.UpdateOptions options)
      Update all documents in the collection according to the specified arguments.
      org.reactivestreams.Publisher<com.mongodb.client.result.UpdateResult> updateOne(org.bson.conversions.Bson filter, org.bson.conversions.Bson update)
      Update a single document in the collection according to the specified arguments.
      org.reactivestreams.Publisher<com.mongodb.client.result.UpdateResult> updateOne(org.bson.conversions.Bson filter, org.bson.conversions.Bson update, com.mongodb.client.model.UpdateOptions options)
      Update a single document in the collection according to the specified arguments.
      MongoCollection<TDocument> withCodecRegistry(org.bson.codecs.configuration.CodecRegistry codecRegistry)
      Create a new MongoCollection instance with a different codec registry.
      <NewTDocument> 
      MongoCollection<NewTDocument>
      withDocumentClass(Class<NewTDocument> clazz)
      Create a new MongoCollection instance with a different default class to cast any documents returned from the database into..
      MongoCollection<TDocument> withReadConcern(com.mongodb.ReadConcern readConcern)
      Create a new MongoCollection instance with a different read concern.
      MongoCollection<TDocument> withReadPreference(com.mongodb.ReadPreference readPreference)
      Create a new MongoCollection instance with a different read preference.
      MongoCollection<TDocument> withWriteConcern(com.mongodb.WriteConcern writeConcern)
      Create a new MongoCollection instance with a different write concern.
    • Method Detail

      • getNamespace

        com.mongodb.MongoNamespace getNamespace()
        Gets the namespace of this collection.
        Returns:
        the namespace
      • getDocumentClass

        Class<TDocument> getDocumentClass()
        Get the class of documents stored in this collection.
        Returns:
        the class
      • getCodecRegistry

        org.bson.codecs.configuration.CodecRegistry getCodecRegistry()
        Get the codec registry for the MongoCollection.
        Returns:
        the CodecRegistry
      • getReadPreference

        com.mongodb.ReadPreference getReadPreference()
        Get the read preference for the MongoCollection.
        Returns:
        the ReadPreference
      • getWriteConcern

        com.mongodb.WriteConcern getWriteConcern()
        Get the write concern for the MongoCollection.
        Returns:
        the WriteConcern
      • getReadConcern

        com.mongodb.ReadConcern getReadConcern()
        Get the read concern for the MongoCollection.
        Returns:
        the ReadConcern
        Since:
        1.2
        Since server release
        3.2
      • withDocumentClass

        <NewTDocument> MongoCollection<NewTDocument> withDocumentClass(Class<NewTDocument> clazz)
        Create a new MongoCollection instance with a different default class to cast any documents returned from the database into..
        Type Parameters:
        NewTDocument - The type that the new collection will encode documents from and decode documents to
        Parameters:
        clazz - the default class to cast any documents returned from the database into.
        Returns:
        a new MongoCollection instance with the different default class
      • withCodecRegistry

        MongoCollection<TDocument> withCodecRegistry(org.bson.codecs.configuration.CodecRegistry codecRegistry)
        Create a new MongoCollection instance with a different codec registry.
        Parameters:
        codecRegistry - the new CodecRegistry for the collection
        Returns:
        a new MongoCollection instance with the different codec registry
      • withReadPreference

        MongoCollection<TDocument> withReadPreference(com.mongodb.ReadPreference readPreference)
        Create a new MongoCollection instance with a different read preference.
        Parameters:
        readPreference - the new ReadPreference for the collection
        Returns:
        a new MongoCollection instance with the different readPreference
      • withWriteConcern

        MongoCollection<TDocument> withWriteConcern(com.mongodb.WriteConcern writeConcern)
        Create a new MongoCollection instance with a different write concern.
        Parameters:
        writeConcern - the new WriteConcern for the collection
        Returns:
        a new MongoCollection instance with the different writeConcern
      • withReadConcern

        MongoCollection<TDocument> withReadConcern(com.mongodb.ReadConcern readConcern)
        Create a new MongoCollection instance with a different read concern.
        Parameters:
        readConcern - the new ReadConcern for the collection
        Returns:
        a new MongoCollection instance with the different ReadConcern
        Since:
        1.2
        Since server release
        3.2
      • count

        org.reactivestreams.Publisher<Long> count()
        Counts the number of documents in the collection.
        Returns:
        a publisher with a single element indicating the number of documents
      • count

        org.reactivestreams.Publisher<Long> count(org.bson.conversions.Bson filter)
        Counts the number of documents in the collection according to the given options.
        Parameters:
        filter - the query filter
        Returns:
        a publisher with a single element indicating the number of documents
      • count

        org.reactivestreams.Publisher<Long> count(org.bson.conversions.Bson filter,
                                                com.mongodb.client.model.CountOptions options)
        Counts the number of documents in the collection according to the given options.
        Parameters:
        filter - the query filter
        options - the options describing the count
        Returns:
        a publisher with a single element indicating the number of documents
      • distinct

        <TResult> DistinctPublisher<TResult> distinct(String fieldName,
                                                    Class<TResult> resultClass)
        Gets the distinct values of the specified field name.
        Type Parameters:
        TResult - the target type of the iterable.
        Parameters:
        fieldName - the field name
        resultClass - the default class to cast any distinct items into.
        Returns:
        a publisher emitting the sequence of distinct values
        MongoDB documentation
        Distinct
      • distinct

        <TResult> DistinctPublisher<TResult> distinct(String fieldName,
                                                    org.bson.conversions.Bson filter,
                                                    Class<TResult> resultClass)
        Gets the distinct values of the specified field name.
        Type Parameters:
        TResult - the target type of the iterable.
        Parameters:
        fieldName - the field name
        filter - the query filter
        resultClass - the default class to cast any distinct items into.
        Returns:
        an iterable of distinct values
        MongoDB documentation
        Distinct
      • find

        FindPublisher<TDocument> find()
        Finds all documents in the collection.
        Returns:
        the fluent find interface
        MongoDB documentation
        Find
      • find

        <TResult> FindPublisher<TResult> find(Class<TResult> clazz)
        Finds all documents in the collection.
        Type Parameters:
        TResult - the target document type of the iterable.
        Parameters:
        clazz - the class to decode each document into
        Returns:
        the fluent find interface
        MongoDB documentation
        Find
      • find

        FindPublisher<TDocument> find(org.bson.conversions.Bson filter)
        Finds all documents in the collection.
        Parameters:
        filter - the query filter
        Returns:
        the fluent find interface
        MongoDB documentation
        Find
      • find

        <TResult> FindPublisher<TResult> find(org.bson.conversions.Bson filter,
                                            Class<TResult> clazz)
        Finds all documents in the collection.
        Type Parameters:
        TResult - the target document type of the iterable.
        Parameters:
        filter - the query filter
        clazz - the class to decode each document into
        Returns:
        the fluent find interface
        MongoDB documentation
        Find
      • aggregate

        AggregatePublisher<org.bson.Document> aggregate(List<? extends org.bson.conversions.Bson> pipeline)
        Aggregates documents according to the specified aggregation pipeline.
        Parameters:
        pipeline - the aggregate pipeline
        Returns:
        a publisher containing the result of the aggregation operation
        MongoDB documentation
        Aggregation
      • aggregate

        <TResult> AggregatePublisher<TResult> aggregate(List<? extends org.bson.conversions.Bson> pipeline,
                                                      Class<TResult> clazz)
        Aggregates documents according to the specified aggregation pipeline.
        Type Parameters:
        TResult - the target document type of the iterable.
        Parameters:
        pipeline - the aggregate pipeline
        clazz - the class to decode each document into
        Returns:
        a publisher containing the result of the aggregation operation
        MongoDB documentation
        Aggregation
      • mapReduce

        MapReducePublisher<org.bson.Document> mapReduce(String mapFunction,
                                                      String reduceFunction)
        Aggregates documents according to the specified map-reduce function.
        Parameters:
        mapFunction - A JavaScript function that associates or "maps" a value with a key and emits the key and value pair.
        reduceFunction - A JavaScript function that "reduces" to a single object all the values associated with a particular key.
        Returns:
        an publisher containing the result of the map-reduce operation
        MongoDB documentation
        map-reduce
      • mapReduce

        <TResult> MapReducePublisher<TResult> mapReduce(String mapFunction,
                                                      String reduceFunction,
                                                      Class<TResult> clazz)
        Aggregates documents according to the specified map-reduce function.
        Type Parameters:
        TResult - the target document type of the iterable.
        Parameters:
        mapFunction - A JavaScript function that associates or "maps" a value with a key and emits the key and value pair.
        reduceFunction - A JavaScript function that "reduces" to a single object all the values associated with a particular key.
        clazz - the class to decode each resulting document into.
        Returns:
        a publisher containing the result of the map-reduce operation
        MongoDB documentation
        map-reduce
      • bulkWrite

        org.reactivestreams.Publisher<com.mongodb.bulk.BulkWriteResult> bulkWrite(List<? extends com.mongodb.client.model.WriteModel<? extends TDocument>> requests)
        Executes a mix of inserts, updates, replaces, and deletes.
        Parameters:
        requests - the writes to execute
        Returns:
        a publisher with a single element the BulkWriteResult
      • bulkWrite

        org.reactivestreams.Publisher<com.mongodb.bulk.BulkWriteResult> bulkWrite(List<? extends com.mongodb.client.model.WriteModel<? extends TDocument>> requests,
                                                                                com.mongodb.client.model.BulkWriteOptions options)
        Executes a mix of inserts, updates, replaces, and deletes.
        Parameters:
        requests - the writes to execute
        options - the options to apply to the bulk write operation
        Returns:
        a publisher with a single element the BulkWriteResult
      • insertOne

        org.reactivestreams.Publisher<Success> insertOne(TDocument document)
        Inserts the provided document. If the document is missing an identifier, the driver should generate one.
        Parameters:
        document - the document to insert
        Returns:
        a publisher with a single element indicating when the operation has completed or with either a com.mongodb.DuplicateKeyException or com.mongodb.MongoException
      • insertOne

        org.reactivestreams.Publisher<Success> insertOne(TDocument document,
                                                       com.mongodb.client.model.InsertOneOptions options)
        Inserts the provided document. If the document is missing an identifier, the driver should generate one.
        Parameters:
        document - the document to insert
        options - the options to apply to the operation
        Returns:
        a publisher with a single element indicating when the operation has completed or with either a com.mongodb.DuplicateKeyException or com.mongodb.MongoException
        Since:
        1.2
      • insertMany

        org.reactivestreams.Publisher<Success> insertMany(List<? extends TDocument> documents)
        Inserts a batch of documents. The preferred way to perform bulk inserts is to use the BulkWrite API. However, when talking with a server < 2.6, using this method will be faster due to constraints in the bulk API related to error handling.
        Parameters:
        documents - the documents to insert
        Returns:
        a publisher with a single element indicating when the operation has completed or with either a com.mongodb.DuplicateKeyException or com.mongodb.MongoException
      • insertMany

        org.reactivestreams.Publisher<Success> insertMany(List<? extends TDocument> documents,
                                                        com.mongodb.client.model.InsertManyOptions options)
        Inserts a batch of documents. The preferred way to perform bulk inserts is to use the BulkWrite API. However, when talking with a server < 2.6, using this method will be faster due to constraints in the bulk API related to error handling.
        Parameters:
        documents - the documents to insert
        options - the options to apply to the operation
        Returns:
        a publisher with a single element indicating when the operation has completed or with either a com.mongodb.DuplicateKeyException or com.mongodb.MongoException
      • deleteOne

        org.reactivestreams.Publisher<com.mongodb.client.result.DeleteResult> deleteOne(org.bson.conversions.Bson filter)
        Removes at most one document from the collection that matches the given filter. If no documents match, the collection is not modified.
        Parameters:
        filter - the query filter to apply the the delete operation
        Returns:
        a publisher with a single element the DeleteResult or with an com.mongodb.MongoException
      • deleteOne

        org.reactivestreams.Publisher<com.mongodb.client.result.DeleteResult> deleteOne(org.bson.conversions.Bson filter,
                                                                                      com.mongodb.client.model.DeleteOptions options)
        Removes at most one document from the collection that matches the given filter. If no documents match, the collection is not modified.
        Parameters:
        filter - the query filter to apply the the delete operation
        options - the options to apply to the delete operation
        Returns:
        a publisher with a single element the DeleteResult or with an com.mongodb.MongoException
        Since:
        1.5
      • deleteMany

        org.reactivestreams.Publisher<com.mongodb.client.result.DeleteResult> deleteMany(org.bson.conversions.Bson filter)
        Removes all documents from the collection that match the given query filter. If no documents match, the collection is not modified.
        Parameters:
        filter - the query filter to apply the the delete operation
        Returns:
        a publisher with a single element the DeleteResult or with an com.mongodb.MongoException
      • deleteMany

        org.reactivestreams.Publisher<com.mongodb.client.result.DeleteResult> deleteMany(org.bson.conversions.Bson filter,
                                                                                       com.mongodb.client.model.DeleteOptions options)
        Removes all documents from the collection that match the given query filter. If no documents match, the collection is not modified.
        Parameters:
        filter - the query filter to apply the the delete operation
        options - the options to apply to the delete operation
        Returns:
        a publisher with a single element the DeleteResult or with an com.mongodb.MongoException
        Since:
        1.5
      • replaceOne

        org.reactivestreams.Publisher<com.mongodb.client.result.UpdateResult> replaceOne(org.bson.conversions.Bson filter,
                                                                                       TDocument replacement)
        Replace a document in the collection according to the specified arguments.
        Parameters:
        filter - the query filter to apply the the replace operation
        replacement - the replacement document
        Returns:
        a publisher with a single element the UpdateResult
        MongoDB documentation
        Replace
      • replaceOne

        org.reactivestreams.Publisher<com.mongodb.client.result.UpdateResult> replaceOne(org.bson.conversions.Bson filter,
                                                                                       TDocument replacement,
                                                                                       com.mongodb.client.model.UpdateOptions options)
        Replace a document in the collection according to the specified arguments.
        Parameters:
        filter - the query filter to apply the the replace operation
        replacement - the replacement document
        options - the options to apply to the replace operation
        Returns:
        a publisher with a single element the UpdateResult
        MongoDB documentation
        Replace
      • updateOne

        org.reactivestreams.Publisher<com.mongodb.client.result.UpdateResult> updateOne(org.bson.conversions.Bson filter,
                                                                                      org.bson.conversions.Bson update)
        Update a single document in the collection according to the specified arguments.
        Parameters:
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        Returns:
        a publisher with a single element the UpdateResult
        MongoDB documentation
        Updates
        Update Operators
      • updateOne

        org.reactivestreams.Publisher<com.mongodb.client.result.UpdateResult> updateOne(org.bson.conversions.Bson filter,
                                                                                      org.bson.conversions.Bson update,
                                                                                      com.mongodb.client.model.UpdateOptions options)
        Update a single document in the collection according to the specified arguments.
        Parameters:
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        options - the options to apply to the update operation
        Returns:
        a publisher with a single element the UpdateResult
        MongoDB documentation
        Updates
        Update Operators
      • updateMany

        org.reactivestreams.Publisher<com.mongodb.client.result.UpdateResult> updateMany(org.bson.conversions.Bson filter,
                                                                                       org.bson.conversions.Bson update)
        Update all documents in the collection according to the specified arguments.
        Parameters:
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        Returns:
        a publisher with a single element the UpdateResult
        MongoDB documentation
        Updates
        Update Operators
      • updateMany

        org.reactivestreams.Publisher<com.mongodb.client.result.UpdateResult> updateMany(org.bson.conversions.Bson filter,
                                                                                       org.bson.conversions.Bson update,
                                                                                       com.mongodb.client.model.UpdateOptions options)
        Update all documents in the collection according to the specified arguments.
        Parameters:
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        options - the options to apply to the update operation
        Returns:
        a publisher with a single element the UpdateResult
        MongoDB documentation
        Updates
        Update Operators
      • findOneAndDelete

        org.reactivestreams.Publisher<TDocument> findOneAndDelete(org.bson.conversions.Bson filter)
        Atomically find a document and remove it.
        Parameters:
        filter - the query filter to find the document with
        Returns:
        a publisher with a single element the document that was removed. If no documents matched the query filter, then null will be returned
      • findOneAndDelete

        org.reactivestreams.Publisher<TDocument> findOneAndDelete(org.bson.conversions.Bson filter,
                                                                com.mongodb.client.model.FindOneAndDeleteOptions options)
        Atomically find a document and remove it.
        Parameters:
        filter - the query filter to find the document with
        options - the options to apply to the operation
        Returns:
        a publisher with a single element the document that was removed. If no documents matched the query filter, then null will be returned
      • findOneAndReplace

        org.reactivestreams.Publisher<TDocument> findOneAndReplace(org.bson.conversions.Bson filter,
                                                                 TDocument replacement)
        Atomically find a document and replace it.
        Parameters:
        filter - the query filter to apply the the replace operation
        replacement - the replacement document
        Returns:
        a publisher with a single element the document that was replaced. Depending on the value of the returnOriginal property, this will either be the document as it was before the update or as it is after the update. If no documents matched the query filter, then null will be returned
      • findOneAndReplace

        org.reactivestreams.Publisher<TDocument> findOneAndReplace(org.bson.conversions.Bson filter,
                                                                 TDocument replacement,
                                                                 com.mongodb.client.model.FindOneAndReplaceOptions options)
        Atomically find a document and replace it.
        Parameters:
        filter - the query filter to apply the the replace operation
        replacement - the replacement document
        options - the options to apply to the operation
        Returns:
        a publisher with a single element the document that was replaced. Depending on the value of the returnOriginal property, this will either be the document as it was before the update or as it is after the update. If no documents matched the query filter, then null will be returned
      • findOneAndUpdate

        org.reactivestreams.Publisher<TDocument> findOneAndUpdate(org.bson.conversions.Bson filter,
                                                                org.bson.conversions.Bson update)
        Atomically find a document and update it.
        Parameters:
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        Returns:
        a publisher with a single element the document that was updated before the update was applied. If no documents matched the query filter, then null will be returned
      • findOneAndUpdate

        org.reactivestreams.Publisher<TDocument> findOneAndUpdate(org.bson.conversions.Bson filter,
                                                                org.bson.conversions.Bson update,
                                                                com.mongodb.client.model.FindOneAndUpdateOptions options)
        Atomically find a document and update it.
        Parameters:
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        options - the options to apply to the operation
        Returns:
        a publisher with a single element the document that was updated. Depending on the value of the returnOriginal property, this will either be the document as it was before the update or as it is after the update. If no documents matched the query filter, then null will be returned
      • drop

        org.reactivestreams.Publisher<Success> drop()
        Drops this collection from the Database.
        Returns:
        a publisher with a single element indicating when the operation has completed
        MongoDB documentation
        Drop Collection
      • createIndex

        org.reactivestreams.Publisher<String> createIndex(org.bson.conversions.Bson key)
        Creates an index.
        Parameters:
        key - an object describing the index key(s), which may not be null.
        Returns:
        a publisher with a single element indicating when the operation has completed
        MongoDB documentation
        Ensure Index
      • createIndex

        org.reactivestreams.Publisher<String> createIndex(org.bson.conversions.Bson key,
                                                        com.mongodb.client.model.IndexOptions options)
        Creates an index.
        Parameters:
        key - an object describing the index key(s), which may not be null.
        options - the options for the index
        Returns:
        a publisher with a single element indicating when the operation has completed
        MongoDB documentation
        Ensure Index
      • createIndexes

        org.reactivestreams.Publisher<String> createIndexes(List<com.mongodb.client.model.IndexModel> indexes)
        Create multiple indexes.
        Parameters:
        indexes - the list of indexes
        Returns:
        a publisher with a single element indicating when the operation has completed
        MongoDB documentation
        Create indexes
        Since server release
        2.6
      • listIndexes

        ListIndexesPublisher<org.bson.Document> listIndexes()
        Get all the indexes in this collection.
        Returns:
        the fluent list indexes interface
        MongoDB documentation
        listIndexes
      • listIndexes

        <TResult> ListIndexesPublisher<TResult> listIndexes(Class<TResult> clazz)
        Get all the indexes in this collection.
        Type Parameters:
        TResult - the target document type of the iterable.
        Parameters:
        clazz - the class to decode each document into
        Returns:
        the fluent list indexes interface
        MongoDB documentation
        listIndexes
      • dropIndex

        org.reactivestreams.Publisher<Success> dropIndex(String indexName)
        Drops the given index.
        Parameters:
        indexName - the name of the index to remove
        Returns:
        a publisher with a single element indicating when the operation has completed
        MongoDB documentation
        Drop Indexes
      • dropIndex

        org.reactivestreams.Publisher<Success> dropIndex(org.bson.conversions.Bson keys)
        Drops the index given the keys used to create it.
        Parameters:
        keys - the keys of the index to remove
        Returns:
        a publisher with a single element indicating when the operation has completed
        MongoDB documentation
        Drop indexes
      • dropIndexes

        org.reactivestreams.Publisher<Success> dropIndexes()
        Drop all the indexes on this collection, except for the default on _id.
        Returns:
        a publisher with a single element indicating when the operation has completed
        MongoDB documentation
        Drop Indexes
      • renameCollection

        org.reactivestreams.Publisher<Success> renameCollection(com.mongodb.MongoNamespace newCollectionNamespace)
        Rename the collection with oldCollectionName to the newCollectionName.
        Parameters:
        newCollectionNamespace - the namespace the collection will be renamed to
        Returns:
        a publisher with a single element indicating when the operation has completed
        MongoDB documentation
        Rename collection
      • renameCollection

        org.reactivestreams.Publisher<Success> renameCollection(com.mongodb.MongoNamespace newCollectionNamespace,
                                                              com.mongodb.client.model.RenameCollectionOptions options)
        Rename the collection with oldCollectionName to the newCollectionName.
        Parameters:
        newCollectionNamespace - the name the collection will be renamed to
        options - the options for renaming a collection
        Returns:
        a publisher with a single element indicating when the operation has completed
        MongoDB documentation
        Rename collection