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 Detail

      • getNamespace

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

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

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

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

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

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

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

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

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

        Publisher<Long> estimatedDocumentCount()
        Gets an estimate of the count of documents in a collection using collection metadata.
        Returns:
        a publisher with a single element indicating the estimated number of documents
        Since:
        1.9
      • estimatedDocumentCount

        Publisher<Long> estimatedDocumentCount​(EstimatedDocumentCountOptions options)
        Gets an estimate of the count of documents in a collection using collection metadata.
        Parameters:
        options - the options describing the count
        Returns:
        a publisher with a single element indicating the estimated number of documents
        Since:
        1.9
      • countDocuments

        Publisher<Long> countDocuments()
        Counts the number of documents in the collection.

        Note: For a fast count of the total documents in a collection see estimatedDocumentCount().
        Note: When migrating from count() to countDocuments() the following query operators must be replaced:

        
          +-------------+--------------------------------+
          | Operator    | Replacement                    |
          +=============+================================+
          | $where      |  $expr                         |
          +-------------+--------------------------------+
          | $near       |  $geoWithin with $center       |
          +-------------+--------------------------------+
          | $nearSphere |  $geoWithin with $centerSphere |
          +-------------+--------------------------------+
         
        Returns:
        a publisher with a single element indicating the number of documents
        Since:
        1.9
      • countDocuments

        Publisher<Long> countDocuments​(Bson filter)
        Counts the number of documents in the collection according to the given options.

        Note: For a fast count of the total documents in a collection see estimatedDocumentCount().
        Note: When migrating from count() to countDocuments() the following query operators must be replaced:

        
          +-------------+--------------------------------+
          | Operator    | Replacement                    |
          +=============+================================+
          | $where      |  $expr                         |
          +-------------+--------------------------------+
          | $near       |  $geoWithin with $center       |
          +-------------+--------------------------------+
          | $nearSphere |  $geoWithin with $centerSphere |
          +-------------+--------------------------------+
         
        Parameters:
        filter - the query filter
        Returns:
        a publisher with a single element indicating the number of documents
        Since:
        1.9
      • countDocuments

        Publisher<Long> countDocuments​(Bson filter,
                                       CountOptions options)
        Counts the number of documents in the collection according to the given options.

        Note: For a fast count of the total documents in a collection see estimatedDocumentCount().
        Note: When migrating from count() to countDocuments() the following query operators must be replaced:

        
          +-------------+--------------------------------+
          | Operator    | Replacement                    |
          +=============+================================+
          | $where      |  $expr                         |
          +-------------+--------------------------------+
          | $near       |  $geoWithin with $center       |
          +-------------+--------------------------------+
          | $nearSphere |  $geoWithin with $centerSphere |
          +-------------+--------------------------------+
         
        Parameters:
        filter - the query filter
        options - the options describing the count
        Returns:
        a publisher with a single element indicating the number of documents
        Since:
        1.9
      • countDocuments

        Publisher<Long> countDocuments​(ClientSession clientSession)
        Counts the number of documents in the collection.

        Note: For a fast count of the total documents in a collection see estimatedDocumentCount().
        Note: When migrating from count() to countDocuments() the following query operators must be replaced:

        
          +-------------+--------------------------------+
          | Operator    | Replacement                    |
          +=============+================================+
          | $where      |  $expr                         |
          +-------------+--------------------------------+
          | $near       |  $geoWithin with $center       |
          +-------------+--------------------------------+
          | $nearSphere |  $geoWithin with $centerSphere |
          +-------------+--------------------------------+
         
        Parameters:
        clientSession - the client session with which to associate this operation
        Returns:
        a publisher with a single element indicating the number of documents
        Since:
        1.9
        Since server release
        3.6
      • countDocuments

        Publisher<Long> countDocuments​(ClientSession clientSession,
                                       Bson filter)
        Counts the number of documents in the collection according to the given options.

        Note: For a fast count of the total documents in a collection see estimatedDocumentCount().

        Parameters:
        clientSession - the client session with which to associate this operation
        filter - the query filter
        Returns:
        a publisher with a single element indicating the number of documents
        Since:
        1.9
        Since server release
        3.6
      • countDocuments

        Publisher<Long> countDocuments​(ClientSession clientSession,
                                       Bson filter,
                                       CountOptions options)
        Counts the number of documents in the collection according to the given options.

        Note: For a fast count of the total documents in a collection see estimatedDocumentCount().
        Note: When migrating from count() to countDocuments() the following query operators must be replaced:

        
          +-------------+--------------------------------+
          | Operator    | Replacement                    |
          +=============+================================+
          | $where      |  $expr                         |
          +-------------+--------------------------------+
          | $near       |  $geoWithin with $center       |
          +-------------+--------------------------------+
          | $nearSphere |  $geoWithin with $centerSphere |
          +-------------+--------------------------------+
         
        Parameters:
        clientSession - the client session with which to associate this operation
        filter - the query filter
        options - the options describing the count
        Returns:
        a publisher with a single element indicating the number of documents
        Since:
        1.9
        Since server release
        3.6
      • distinct

        <TResult> DistinctPublisher<TResult> distinct​(String fieldName,
                                                      Class<TResult> resultClass)
        Gets the distinct values of the specified field name.
        Type Parameters:
        TResult - the target type of the iterable.
        Parameters:
        fieldName - the field 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,
                                                      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
      • distinct

        <TResult> DistinctPublisher<TResult> distinct​(ClientSession clientSession,
                                                      String fieldName,
                                                      Class<TResult> resultClass)
        Gets the distinct values of the specified field name.
        Type Parameters:
        TResult - the target type of the iterable.
        Parameters:
        clientSession - the client session with which to associate this operation
        fieldName - the field name
        resultClass - the default class to cast any distinct items into.
        Returns:
        a publisher emitting the sequence of distinct values
        Since:
        1.7
        MongoDB documentation
        Distinct
        Since server release
        3.6
      • distinct

        <TResult> DistinctPublisher<TResult> distinct​(ClientSession clientSession,
                                                      String fieldName,
                                                      Bson filter,
                                                      Class<TResult> resultClass)
        Gets the distinct values of the specified field name.
        Type Parameters:
        TResult - the target type of the iterable.
        Parameters:
        clientSession - the client session with which to associate this operation
        fieldName - the field name
        filter - the query filter
        resultClass - the default class to cast any distinct items into.
        Returns:
        an iterable of distinct values
        Since:
        1.7
        MongoDB documentation
        Distinct
        Since server release
        3.6
      • find

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

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

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

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

        FindPublisher<TDocument> find​(ClientSession clientSession)
        Finds all documents in the collection.
        Parameters:
        clientSession - the client session with which to associate this operation
        Returns:
        the fluent find interface
        Since:
        1.7
        MongoDB documentation
        Find
        Since server release
        3.6
      • find

        <TResult> FindPublisher<TResult> find​(ClientSession clientSession,
                                              Class<TResult> clazz)
        Finds all documents in the collection.
        Type Parameters:
        TResult - the target document type of the iterable.
        Parameters:
        clientSession - the client session with which to associate this operation
        clazz - the class to decode each document into
        Returns:
        the fluent find interface
        Since:
        1.7
        MongoDB documentation
        Find
        Since server release
        3.6
      • find

        FindPublisher<TDocument> find​(ClientSession clientSession,
                                      Bson filter)
        Finds all documents in the collection.
        Parameters:
        clientSession - the client session with which to associate this operation
        filter - the query filter
        Returns:
        the fluent find interface
        Since:
        1.7
        MongoDB documentation
        Find
        Since server release
        3.6
      • find

        <TResult> FindPublisher<TResult> find​(ClientSession clientSession,
                                              Bson filter,
                                              Class<TResult> clazz)
        Finds all documents in the collection.
        Type Parameters:
        TResult - the target document type of the iterable.
        Parameters:
        clientSession - the client session with which to associate this operation
        filter - the query filter
        clazz - the class to decode each document into
        Returns:
        the fluent find interface
        Since:
        1.7
        MongoDB documentation
        Find
        Since server release
        3.6
      • aggregate

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

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

        AggregatePublisher<TDocument> aggregate​(ClientSession clientSession,
                                                List<? extends Bson> pipeline)
        Aggregates documents according to the specified aggregation pipeline.
        Parameters:
        clientSession - the client session with which to associate this operation
        pipeline - the aggregate pipeline
        Returns:
        a publisher containing the result of the aggregation operation
        Since:
        1.7
        MongoDB documentation
        Aggregation
        Since server release
        3.6
      • aggregate

        <TResult> AggregatePublisher<TResult> aggregate​(ClientSession clientSession,
                                                        List<? extends Bson> pipeline,
                                                        Class<TResult> clazz)
        Aggregates documents according to the specified aggregation pipeline.
        Type Parameters:
        TResult - the target document type of the iterable.
        Parameters:
        clientSession - the client session with which to associate this operation
        pipeline - the aggregate pipeline
        clazz - the class to decode each document into
        Returns:
        a publisher containing the result of the aggregation operation
        Since:
        1.7
        MongoDB documentation
        Aggregation
        Since server release
        3.6
      • watch

        <TResult> ChangeStreamPublisher<TResult> watch​(Class<TResult> resultClass)
        Creates a change stream for this collection.
        Type Parameters:
        TResult - the target document type of the iterable.
        Parameters:
        resultClass - the class to decode each document into
        Returns:
        the change stream iterable
        Since:
        1.7
        MongoDB documentation
        $changeStream
        Since server release
        3.6
      • watch

        ChangeStreamPublisher<Document> watch​(List<? extends Bson> pipeline)
        Creates a change stream for this collection.
        Parameters:
        pipeline - the aggregation pipeline to apply to the change stream
        Returns:
        the change stream iterable
        Since:
        1.6
        MongoDB documentation
        $changeStream
      • watch

        <TResult> ChangeStreamPublisher<TResult> watch​(List<? extends Bson> pipeline,
                                                       Class<TResult> resultClass)
        Creates a change stream for this collection.
        Type Parameters:
        TResult - the target document type of the iterable.
        Parameters:
        pipeline - the aggregation pipeline to apply to the change stream
        resultClass - the class to decode each document into
        Returns:
        the change stream iterable
        Since:
        1.6
        MongoDB documentation
        $changeStream
      • watch

        ChangeStreamPublisher<Document> watch​(ClientSession clientSession)
        Creates a change stream for this collection.
        Parameters:
        clientSession - the client session with which to associate this operation
        Returns:
        the change stream iterable
        Since:
        1.7
        MongoDB documentation
        $changeStream
        Since server release
        3.6
      • watch

        <TResult> ChangeStreamPublisher<TResult> watch​(ClientSession clientSession,
                                                       Class<TResult> resultClass)
        Creates a change stream for this collection.
        Type Parameters:
        TResult - the target document type of the iterable.
        Parameters:
        clientSession - the client session with which to associate this operation
        resultClass - the class to decode each document into
        Returns:
        the change stream iterable
        Since:
        1.7
        MongoDB documentation
        $changeStream
        Since server release
        3.6
      • watch

        ChangeStreamPublisher<Document> watch​(ClientSession clientSession,
                                              List<? extends Bson> pipeline)
        Creates a change stream for this collection.
        Parameters:
        clientSession - the client session with which to associate this operation
        pipeline - the aggregation pipeline to apply to the change stream
        Returns:
        the change stream iterable
        Since:
        1.7
        MongoDB documentation
        $changeStream
        Since server release
        3.6
      • watch

        <TResult> ChangeStreamPublisher<TResult> watch​(ClientSession clientSession,
                                                       List<? extends Bson> pipeline,
                                                       Class<TResult> resultClass)
        Creates a change stream for this collection.
        Type Parameters:
        TResult - the target document type of the iterable.
        Parameters:
        clientSession - the client session with which to associate this operation
        pipeline - the aggregation pipeline to apply to the change stream
        resultClass - the class to decode each document into
        Returns:
        the change stream iterable
        Since:
        1.7
        MongoDB documentation
        $changeStream
        Since server release
        3.6
      • mapReduce

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

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

        MapReducePublisher<TDocument> mapReduce​(ClientSession clientSession,
                                                String mapFunction,
                                                String reduceFunction)
        Aggregates documents according to the specified map-reduce function.
        Parameters:
        clientSession - the client session with which to associate this operation
        mapFunction - A JavaScript function that associates or "maps" a value with a key and emits the key and value pair.
        reduceFunction - A JavaScript function that "reduces" to a single object all the values associated with a particular key.
        Returns:
        an publisher containing the result of the map-reduce operation
        Since:
        1.7
        MongoDB documentation
        map-reduce
        Since server release
        3.6
      • mapReduce

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

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

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

        Publisher<BulkWriteResult> bulkWrite​(ClientSession clientSession,
                                             List<? extends WriteModel<? extends TDocument>> requests)
        Executes a mix of inserts, updates, replaces, and deletes.
        Parameters:
        clientSession - the client session with which to associate this operation
        requests - the writes to execute
        Returns:
        a publisher with a single element the BulkWriteResult
        Since:
        1.7
        Since server release
        3.6
      • bulkWrite

        Publisher<BulkWriteResult> bulkWrite​(ClientSession clientSession,
                                             List<? extends WriteModel<? extends TDocument>> requests,
                                             BulkWriteOptions options)
        Executes a mix of inserts, updates, replaces, and deletes.
        Parameters:
        clientSession - the client session with which to associate this operation
        requests - the writes to execute
        options - the options to apply to the bulk write operation
        Returns:
        a publisher with a single element the BulkWriteResult
        Since:
        1.7
        Since server release
        3.6
      • insertOne

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

        Publisher<InsertOneResult> insertOne​(TDocument document,
                                             InsertOneOptions options)
        Inserts the provided document. If the document is missing an identifier, the driver should generate one.
        Parameters:
        document - the document to insert
        options - the options to apply to the operation
        Returns:
        a publisher with a single element with the InsertOneResult or with either a com.mongodb.DuplicateKeyException or com.mongodb.MongoException
        Since:
        1.2
      • insertOne

        Publisher<InsertOneResult> insertOne​(ClientSession clientSession,
                                             TDocument document)
        Inserts the provided document. If the document is missing an identifier, the driver should generate one.
        Parameters:
        clientSession - the client session with which to associate this operation
        document - the document to insert
        Returns:
        a publisher with a single element with the InsertOneResult or with either a com.mongodb.DuplicateKeyException or com.mongodb.MongoException
        Since:
        1.7
        Since server release
        3.6
      • insertOne

        Publisher<InsertOneResult> insertOne​(ClientSession clientSession,
                                             TDocument document,
                                             InsertOneOptions options)
        Inserts the provided document. If the document is missing an identifier, the driver should generate one.
        Parameters:
        clientSession - the client session with which to associate this operation
        document - the document to insert
        options - the options to apply to the operation
        Returns:
        a publisher with a single element with the InsertOneResult or with either a com.mongodb.DuplicateKeyException or com.mongodb.MongoException
        Since:
        1.7
        Since server release
        3.6
      • insertMany

        Publisher<InsertManyResult> insertMany​(List<? extends TDocument> documents)
        Inserts a batch of documents.
        Parameters:
        documents - the documents to insert
        Returns:
        a publisher with a single element with the InsertManyResult or with either a com.mongodb.DuplicateKeyException or com.mongodb.MongoException
      • insertMany

        Publisher<InsertManyResult> insertMany​(List<? extends TDocument> documents,
                                               InsertManyOptions options)
        Inserts a batch of documents.
        Parameters:
        documents - the documents to insert
        options - the options to apply to the operation
        Returns:
        a publisher with a single element with the InsertManyResult or with either a com.mongodb.DuplicateKeyException or com.mongodb.MongoException
      • insertMany

        Publisher<InsertManyResult> insertMany​(ClientSession clientSession,
                                               List<? extends TDocument> documents)
        Inserts a batch of documents.
        Parameters:
        clientSession - the client session with which to associate this operation
        documents - the documents to insert
        Returns:
        a publisher with a single element with the InsertManyResult or with either a com.mongodb.DuplicateKeyException or com.mongodb.MongoException
        Since:
        1.7
        Since server release
        3.6
      • insertMany

        Publisher<InsertManyResult> insertMany​(ClientSession clientSession,
                                               List<? extends TDocument> documents,
                                               InsertManyOptions options)
        Inserts a batch of documents.
        Parameters:
        clientSession - the client session with which to associate this operation
        documents - the documents to insert
        options - the options to apply to the operation
        Returns:
        a publisher with a single element with the InsertManyResult or with either a com.mongodb.DuplicateKeyException or com.mongodb.MongoException
        Since:
        1.7
        Since server release
        3.6
      • deleteOne

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

        Publisher<DeleteResult> deleteOne​(Bson filter,
                                          DeleteOptions options)
        Removes at most one document from the collection that matches the given filter. If no documents match, the collection is not modified.
        Parameters:
        filter - the query filter to apply the the delete 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
      • deleteOne

        Publisher<DeleteResult> deleteOne​(ClientSession clientSession,
                                          Bson filter)
        Removes at most one document from the collection that matches the given filter. If no documents match, the collection is not modified.
        Parameters:
        clientSession - the client session with which to associate this operation
        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
        Since:
        1.7
        Since server release
        3.6
      • deleteOne

        Publisher<DeleteResult> deleteOne​(ClientSession clientSession,
                                          Bson filter,
                                          DeleteOptions options)
        Removes at most one document from the collection that matches the given filter. If no documents match, the collection is not modified.
        Parameters:
        clientSession - the client session with which to associate this operation
        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.7
        Since server release
        3.6
      • deleteMany

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

        Publisher<DeleteResult> deleteMany​(Bson filter,
                                           DeleteOptions options)
        Removes all documents from the collection that match the given query filter. If no documents match, the collection is not modified.
        Parameters:
        filter - the query filter to apply the the delete 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

        Publisher<DeleteResult> deleteMany​(ClientSession clientSession,
                                           Bson filter)
        Removes all documents from the collection that match the given query filter. If no documents match, the collection is not modified.
        Parameters:
        clientSession - the client session with which to associate this operation
        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
        Since:
        1.7
        Since server release
        3.6
      • deleteMany

        Publisher<DeleteResult> deleteMany​(ClientSession clientSession,
                                           Bson filter,
                                           DeleteOptions options)
        Removes all documents from the collection that match the given query filter. If no documents match, the collection is not modified.
        Parameters:
        clientSession - the client session with which to associate this operation
        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.7
        Since server release
        3.6
      • replaceOne

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

        Publisher<UpdateResult> replaceOne​(Bson filter,
                                           TDocument replacement,
                                           ReplaceOptions options)
        Replace a document in the collection according to the specified arguments.
        Parameters:
        filter - the query filter to apply the the replace operation
        replacement - the replacement document
        options - the options to apply to the replace operation
        Returns:
        a publisher with a single element the UpdateResult
        Since:
        1.8
        MongoDB documentation
        Replace
      • replaceOne

        Publisher<UpdateResult> replaceOne​(ClientSession clientSession,
                                           Bson filter,
                                           TDocument replacement)
        Replace a document in the collection according to the specified arguments.
        Parameters:
        clientSession - the client session with which to associate this operation
        filter - the query filter to apply the the replace operation
        replacement - the replacement document
        Returns:
        a publisher with a single element the UpdateResult
        Since:
        1.7
        MongoDB documentation
        Replace
        Since server release
        3.6
      • replaceOne

        Publisher<UpdateResult> replaceOne​(ClientSession clientSession,
                                           Bson filter,
                                           TDocument replacement,
                                           ReplaceOptions options)
        Replace a document in the collection according to the specified arguments.
        Parameters:
        clientSession - the client session with which to associate this operation
        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
        Since:
        1.8
        MongoDB documentation
        Replace
        Since server release
        3.6
      • updateOne

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

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

        Publisher<UpdateResult> updateOne​(ClientSession clientSession,
                                          Bson filter,
                                          Bson update)
        Update a single document in the collection according to the specified arguments.
        Parameters:
        clientSession - the client session with which to associate this operation
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        Returns:
        a publisher with a single element the UpdateResult
        Since:
        1.7
        MongoDB documentation
        Updates
        Update Operators
        Since server release
        3.6
      • updateOne

        Publisher<UpdateResult> updateOne​(ClientSession clientSession,
                                          Bson filter,
                                          Bson update,
                                          UpdateOptions options)
        Update a single document in the collection according to the specified arguments.
        Parameters:
        clientSession - the client session with which to associate this operation
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        options - the options to apply to the update operation
        Returns:
        a publisher with a single element the UpdateResult
        Since:
        1.7
        MongoDB documentation
        Updates
        Update Operators
        Since server release
        3.6
      • updateOne

        Publisher<UpdateResult> updateOne​(Bson filter,
                                          List<? extends Bson> update)
        Update a single document in the collection according to the specified arguments.

        Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.

        Parameters:
        filter - a document describing the query filter, which may not be null.
        update - a pipeline describing the update, which may not be null.
        Returns:
        a publisher with a single element the UpdateResult
        Since:
        1.12
        MongoDB documentation
        Updates
        Update Operators
        Since server release
        4.2
      • updateOne

        Publisher<UpdateResult> updateOne​(Bson filter,
                                          List<? extends Bson> update,
                                          UpdateOptions options)
        Update a single document in the collection according to the specified arguments.

        Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.

        Parameters:
        filter - a document describing the query filter, which may not be null.
        update - a pipeline describing the update, which may not be null.
        options - the options to apply to the update operation
        Returns:
        a publisher with a single element the UpdateResult
        Since:
        1.12
        MongoDB documentation
        Updates
        Update Operators
        Since server release
        4.2
      • updateOne

        Publisher<UpdateResult> updateOne​(ClientSession clientSession,
                                          Bson filter,
                                          List<? extends Bson> update)
        Update a single document in the collection according to the specified arguments.

        Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.

        Parameters:
        clientSession - the client session with which to associate this operation
        filter - a document describing the query filter, which may not be null.
        update - a pipeline describing the update, which may not be null.
        Returns:
        a publisher with a single element the UpdateResult
        Since:
        1.12
        MongoDB documentation
        Updates
        Update Operators
        Since server release
        4.2
      • updateOne

        Publisher<UpdateResult> updateOne​(ClientSession clientSession,
                                          Bson filter,
                                          List<? extends Bson> update,
                                          UpdateOptions options)
        Update a single document in the collection according to the specified arguments.

        Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.

        Parameters:
        clientSession - the client session with which to associate this operation
        filter - a document describing the query filter, which may not be null.
        update - a pipeline describing the update, which may not be null.
        options - the options to apply to the update operation
        Returns:
        a publisher with a single element the UpdateResult
        Since:
        1.12
        MongoDB documentation
        Updates
        Update Operators
        Since server release
        4.2
      • updateMany

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

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

        Publisher<UpdateResult> updateMany​(ClientSession clientSession,
                                           Bson filter,
                                           Bson update)
        Update all documents in the collection according to the specified arguments.
        Parameters:
        clientSession - the client session with which to associate this operation
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        Returns:
        a publisher with a single element the UpdateResult
        Since:
        1.7
        MongoDB documentation
        Updates
        Update Operators
        Since server release
        3.6
      • updateMany

        Publisher<UpdateResult> updateMany​(ClientSession clientSession,
                                           Bson filter,
                                           Bson update,
                                           UpdateOptions options)
        Update all documents in the collection according to the specified arguments.
        Parameters:
        clientSession - the client session with which to associate this operation
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        options - the options to apply to the update operation
        Returns:
        a publisher with a single element the UpdateResult
        Since:
        1.7
        MongoDB documentation
        Updates
        Update Operators
        Since server release
        3.6
      • updateMany

        Publisher<UpdateResult> updateMany​(Bson filter,
                                           List<? extends Bson> update)
        Update all documents in the collection according to the specified arguments.
        Parameters:
        filter - a document describing the query filter, which may not be null.
        update - a pipeline describing the update, which may not be null.
        Returns:
        a publisher with a single element the UpdateResult
        Since:
        1.12
        MongoDB documentation
        Updates
        Update Operators
        Since server release
        4.2
      • updateMany

        Publisher<UpdateResult> updateMany​(Bson filter,
                                           List<? extends Bson> update,
                                           UpdateOptions options)
        Update all documents in the collection according to the specified arguments.
        Parameters:
        filter - a document describing the query filter, which may not be null.
        update - a pipeline describing the update, which may not be null.
        options - the options to apply to the update operation
        Returns:
        a publisher with a single element the UpdateResult
        Since:
        1.12
        MongoDB documentation
        Updates
        Update Operators
        Since server release
        4.2
      • updateMany

        Publisher<UpdateResult> updateMany​(ClientSession clientSession,
                                           Bson filter,
                                           List<? extends Bson> update)
        Update all documents in the collection according to the specified arguments.
        Parameters:
        clientSession - the client session with which to associate this operation
        filter - a document describing the query filter, which may not be null.
        update - a pipeline describing the update, which may not be null.
        Returns:
        a publisher with a single element the UpdateResult
        Since:
        1.12
        MongoDB documentation
        Updates
        Update Operators
        Since server release
        4.2
      • updateMany

        Publisher<UpdateResult> updateMany​(ClientSession clientSession,
                                           Bson filter,
                                           List<? extends Bson> update,
                                           UpdateOptions options)
        Update all documents in the collection according to the specified arguments.
        Parameters:
        clientSession - the client session with which to associate this operation
        filter - a document describing the query filter, which may not be null.
        update - a pipeline describing the update, which may not be null.
        options - the options to apply to the update operation
        Returns:
        a publisher with a single element the UpdateResult
        Since:
        1.12
        MongoDB documentation
        Updates
        Update Operators
        Since server release
        4.2
      • findOneAndDelete

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

        Publisher<TDocument> findOneAndDelete​(Bson filter,
                                              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
      • findOneAndDelete

        Publisher<TDocument> findOneAndDelete​(ClientSession clientSession,
                                              Bson filter)
        Atomically find a document and remove it.
        Parameters:
        clientSession - the client session with which to associate this operation
        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
        Since:
        1.7
        Since server release
        3.6
      • findOneAndDelete

        Publisher<TDocument> findOneAndDelete​(ClientSession clientSession,
                                              Bson filter,
                                              FindOneAndDeleteOptions options)
        Atomically find a document and remove it.
        Parameters:
        clientSession - the client session with which to associate this operation
        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
        Since:
        1.7
        Since server release
        3.6
      • findOneAndReplace

        Publisher<TDocument> findOneAndReplace​(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

        Publisher<TDocument> findOneAndReplace​(Bson filter,
                                               TDocument replacement,
                                               FindOneAndReplaceOptions options)
        Atomically find a document and replace it.
        Parameters:
        filter - the query filter to apply the the replace 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
      • findOneAndReplace

        Publisher<TDocument> findOneAndReplace​(ClientSession clientSession,
                                               Bson filter,
                                               TDocument replacement)
        Atomically find a document and replace it.
        Parameters:
        clientSession - the client session with which to associate this operation
        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
        Since:
        1.7
        Since server release
        3.6
      • findOneAndReplace

        Publisher<TDocument> findOneAndReplace​(ClientSession clientSession,
                                               Bson filter,
                                               TDocument replacement,
                                               FindOneAndReplaceOptions options)
        Atomically find a document and replace it.
        Parameters:
        clientSession - the client session with which to associate this operation
        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
        Since:
        1.7
        Since server release
        3.6
      • findOneAndUpdate

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

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

        Publisher<TDocument> findOneAndUpdate​(ClientSession clientSession,
                                              Bson filter,
                                              Bson update)
        Atomically find a document and update it.
        Parameters:
        clientSession - the client session with which to associate this operation
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        Returns:
        a publisher with a single element the document that was updated before the update was applied. If no documents matched the query filter, then null will be returned
        Since:
        1.7
        Since server release
        3.6
      • findOneAndUpdate

        Publisher<TDocument> findOneAndUpdate​(ClientSession clientSession,
                                              Bson filter,
                                              Bson update,
                                              FindOneAndUpdateOptions options)
        Atomically find a document and update it.
        Parameters:
        clientSession - the client session with which to associate this operation
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        options - the options to apply to the operation
        Returns:
        a publisher with a single element the document that was updated. Depending on the value of the returnOriginal property, this will either be the document as it was before the update or as it is after the update. If no documents matched the query filter, then null will be returned
        Since:
        1.7
        Since server release
        3.6
      • findOneAndUpdate

        Publisher<TDocument> findOneAndUpdate​(Bson filter,
                                              List<? extends Bson> update)
        Atomically find a document and update it.

        Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.

        Parameters:
        filter - a document describing the query filter, which may not be null.
        update - a pipeline describing the update, which may not be null.
        Returns:
        a publisher with a single element the document that was updated. Depending on the value of the returnOriginal property, this will either be the document as it was before the update or as it is after the update. If no documents matched the query filter, then null will be returned
        Since:
        1.12
        Since server release
        4.2
      • findOneAndUpdate

        Publisher<TDocument> findOneAndUpdate​(Bson filter,
                                              List<? extends Bson> update,
                                              FindOneAndUpdateOptions options)
        Atomically find a document and update it.

        Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.

        Parameters:
        filter - a document describing the query filter, which may not be null.
        update - a pipeline describing the update, which may not be null.
        options - the options to apply to the operation
        Returns:
        a publisher with a single element the document that was updated. Depending on the value of the returnOriginal property, this will either be the document as it was before the update or as it is after the update. If no documents matched the query filter, then null will be returned
        Since:
        1.12
        Since server release
        4.2
      • findOneAndUpdate

        Publisher<TDocument> findOneAndUpdate​(ClientSession clientSession,
                                              Bson filter,
                                              List<? extends Bson> update)
        Atomically find a document and update it.

        Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.

        Parameters:
        clientSession - the client session with which to associate this operation
        filter - a document describing the query filter, which may not be null.
        update - a pipeline describing the update, which may not be null.
        Returns:
        a publisher with a single element the document that was updated. Depending on the value of the returnOriginal property, this will either be the document as it was before the update or as it is after the update. If no documents matched the query filter, then null will be returned
        Since:
        1.12
        Since server release
        4.2
      • findOneAndUpdate

        Publisher<TDocument> findOneAndUpdate​(ClientSession clientSession,
                                              Bson filter,
                                              List<? extends Bson> update,
                                              FindOneAndUpdateOptions options)
        Atomically find a document and update it.

        Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.

        Parameters:
        clientSession - the client session with which to associate this operation
        filter - a document describing the query filter, which may not be null.
        update - a pipeline describing the update, which may not be null.
        options - the options to apply to the operation
        Returns:
        a publisher with a single element the document that was updated. Depending on the value of the returnOriginal property, this will either be the document as it was before the update or as it is after the update. If no documents matched the query filter, then null will be returned
        Since:
        1.12
        Since server release
        4.2
      • drop

        Publisher<Void> drop()
        Drops this collection from the Database.
        Returns:
        an empty publisher that indicates when the operation has completed
        MongoDB documentation
        Drop Collection
      • drop

        Publisher<Void> drop​(ClientSession clientSession)
        Drops this collection from the Database.
        Parameters:
        clientSession - the client session with which to associate this operation
        Returns:
        an empty publisher that indicates when the operation has completed
        Since:
        1.7
        MongoDB documentation
        Drop Collection
        Since server release
        3.6
      • createIndex

        Publisher<String> createIndex​(Bson key)
        Creates an index.
        Parameters:
        key - an object describing the index key(s), which may not be null.
        Returns:
        an empty publisher that indicates when the operation has completed
        MongoDB documentation
        Ensure Index
      • createIndex

        Publisher<String> createIndex​(Bson key,
                                      IndexOptions options)
        Creates an index.
        Parameters:
        key - an object describing the index key(s), which may not be null.
        options - the options for the index
        Returns:
        an empty publisher that indicates when the operation has completed
        MongoDB documentation
        Ensure Index
      • createIndex

        Publisher<String> createIndex​(ClientSession clientSession,
                                      Bson key)
        Creates an index.
        Parameters:
        clientSession - the client session with which to associate this operation
        key - an object describing the index key(s), which may not be null.
        Returns:
        an empty publisher that indicates when the operation has completed
        Since:
        1.7
        MongoDB documentation
        Ensure Index
        Since server release
        3.6
      • createIndex

        Publisher<String> createIndex​(ClientSession clientSession,
                                      Bson key,
                                      IndexOptions options)
        Creates an index.
        Parameters:
        clientSession - the client session with which to associate this operation
        key - an object describing the index key(s), which may not be null.
        options - the options for the index
        Returns:
        an empty publisher that indicates when the operation has completed
        Since:
        1.7
        MongoDB documentation
        Ensure Index
        Since server release
        3.6
      • createIndexes

        Publisher<String> createIndexes​(List<IndexModel> indexes)
        Create multiple indexes.
        Parameters:
        indexes - the list of indexes
        Returns:
        an empty publisher that indicates when the operation has completed
        MongoDB documentation
        Create indexes
      • createIndexes

        Publisher<String> createIndexes​(List<IndexModel> indexes,
                                        CreateIndexOptions createIndexOptions)
        Create multiple indexes.
        Parameters:
        indexes - the list of indexes
        createIndexOptions - options to use when creating indexes
        Returns:
        an empty publisher that indicates when the operation has completed
        Since:
        1.7
        MongoDB documentation
        Create indexes
      • createIndexes

        Publisher<String> createIndexes​(ClientSession clientSession,
                                        List<IndexModel> indexes)
        Create multiple indexes.
        Parameters:
        clientSession - the client session with which to associate this operation
        indexes - the list of indexes
        Returns:
        an empty publisher that indicates when the operation has completed
        Since:
        1.7
        MongoDB documentation
        Create indexes
        Since server release
        3.6
      • createIndexes

        Publisher<String> createIndexes​(ClientSession clientSession,
                                        List<IndexModel> indexes,
                                        CreateIndexOptions createIndexOptions)
        Create multiple indexes.
        Parameters:
        clientSession - the client session with which to associate this operation
        indexes - the list of indexes
        createIndexOptions - options to use when creating indexes
        Returns:
        an empty publisher that indicates when the operation has completed
        Since:
        1.7
        MongoDB documentation
        Create indexes
        Since server release
        3.6
      • listIndexes

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

        ListIndexesPublisher<Document> listIndexes​(ClientSession clientSession)
        Get all the indexes in this collection.
        Parameters:
        clientSession - the client session with which to associate this operation
        Returns:
        the fluent list indexes interface
        Since:
        1.7
        MongoDB documentation
        listIndexes
        Since server release
        3.6
      • listIndexes

        <TResult> ListIndexesPublisher<TResult> listIndexes​(ClientSession clientSession,
                                                            Class<TResult> clazz)
        Get all the indexes in this collection.
        Type Parameters:
        TResult - the target document type of the iterable.
        Parameters:
        clientSession - the client session with which to associate this operation
        clazz - the class to decode each document into
        Returns:
        the fluent list indexes interface
        Since:
        1.7
        MongoDB documentation
        listIndexes
        Since server release
        3.6
      • dropIndex

        Publisher<Void> dropIndex​(String indexName)
        Drops the given index.
        Parameters:
        indexName - the name of the index to remove
        Returns:
        an empty publisher that indicates when the operation has completed
        MongoDB documentation
        Drop Indexes
      • dropIndex

        Publisher<Void> dropIndex​(Bson keys)
        Drops the index given the keys used to create it.
        Parameters:
        keys - the keys of the index to remove
        Returns:
        an empty publisher that indicates when the operation has completed
        MongoDB documentation
        Drop indexes
      • dropIndex

        Publisher<Void> dropIndex​(String indexName,
                                  DropIndexOptions dropIndexOptions)
        Drops the given index.
        Parameters:
        indexName - the name of the index to remove
        dropIndexOptions - options to use when dropping indexes
        Returns:
        an empty publisher that indicates when the operation has completed
        Since:
        1.7
        MongoDB documentation
        Drop Indexes
      • dropIndex

        Publisher<Void> dropIndex​(Bson keys,
                                  DropIndexOptions dropIndexOptions)
        Drops the index given the keys used to create it.
        Parameters:
        keys - the keys of the index to remove
        dropIndexOptions - options to use when dropping indexes
        Returns:
        an empty publisher that indicates when the operation has completed
        Since:
        1.7
        MongoDB documentation
        Drop indexes
      • dropIndex

        Publisher<Void> dropIndex​(ClientSession clientSession,
                                  String indexName)
        Drops the given index.
        Parameters:
        clientSession - the client session with which to associate this operation
        indexName - the name of the index to remove
        Returns:
        an empty publisher that indicates when the operation has completed
        Since:
        1.7
        MongoDB documentation
        Drop Indexes
        Since server release
        3.6
      • dropIndex

        Publisher<Void> dropIndex​(ClientSession clientSession,
                                  Bson keys)
        Drops the index given the keys used to create it.
        Parameters:
        clientSession - the client session with which to associate this operation
        keys - the keys of the index to remove
        Returns:
        an empty publisher that indicates when the operation has completed
        Since:
        1.7
        MongoDB documentation
        Drop indexes
        Since server release
        3.6
      • dropIndex

        Publisher<Void> dropIndex​(ClientSession clientSession,
                                  String indexName,
                                  DropIndexOptions dropIndexOptions)
        Drops the given index.
        Parameters:
        clientSession - the client session with which to associate this operation
        indexName - the name of the index to remove
        dropIndexOptions - options to use when dropping indexes
        Returns:
        an empty publisher that indicates when the operation has completed
        Since:
        1.7
        MongoDB documentation
        Drop Indexes
        Since server release
        3.6
      • dropIndex

        Publisher<Void> dropIndex​(ClientSession clientSession,
                                  Bson keys,
                                  DropIndexOptions dropIndexOptions)
        Drops the index given the keys used to create it.
        Parameters:
        clientSession - the client session with which to associate this operation
        keys - the keys of the index to remove
        dropIndexOptions - options to use when dropping indexes
        Returns:
        an empty publisher that indicates when the operation has completed
        Since:
        1.7
        MongoDB documentation
        Drop indexes
        Since server release
        3.6
      • dropIndexes

        Publisher<Void> dropIndexes()
        Drop all the indexes on this collection, except for the default on _id.
        Returns:
        an empty publisher that indicates when the operation has completed
        MongoDB documentation
        Drop Indexes
      • dropIndexes

        Publisher<Void> dropIndexes​(DropIndexOptions dropIndexOptions)
        Drop all the indexes on this collection, except for the default on _id.
        Parameters:
        dropIndexOptions - options to use when dropping indexes
        Returns:
        an empty publisher that indicates when the operation has completed
        Since:
        1.7
        MongoDB documentation
        Drop Indexes
      • dropIndexes

        Publisher<Void> dropIndexes​(ClientSession clientSession)
        Drop all the indexes on this collection, except for the default on _id.
        Parameters:
        clientSession - the client session with which to associate this operation
        Returns:
        an empty publisher that indicates when the operation has completed
        Since:
        1.7
        MongoDB documentation
        Drop Indexes
        Since server release
        3.6
      • dropIndexes

        Publisher<Void> dropIndexes​(ClientSession clientSession,
                                    DropIndexOptions dropIndexOptions)
        Drop all the indexes on this collection, except for the default on _id.
        Parameters:
        clientSession - the client session with which to associate this operation
        dropIndexOptions - options to use when dropping indexes
        Returns:
        an empty publisher that indicates when the operation has completed
        Since:
        1.7
        MongoDB documentation
        Drop Indexes
        Since server release
        3.6
      • renameCollection

        Publisher<Void> renameCollection​(MongoNamespace newCollectionNamespace)
        Rename the collection with oldCollectionName to the newCollectionName.
        Parameters:
        newCollectionNamespace - the namespace the collection will be renamed to
        Returns:
        an empty publisher that indicates when the operation has completed
        MongoDB documentation
        Rename collection
      • renameCollection

        Publisher<Void> renameCollection​(MongoNamespace newCollectionNamespace,
                                         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:
        an empty publisher that indicates when the operation has completed
        MongoDB documentation
        Rename collection
      • renameCollection

        Publisher<Void> renameCollection​(ClientSession clientSession,
                                         MongoNamespace newCollectionNamespace)
        Rename the collection with oldCollectionName to the newCollectionName.
        Parameters:
        clientSession - the client session with which to associate this operation
        newCollectionNamespace - the namespace the collection will be renamed to
        Returns:
        an empty publisher that indicates when the operation has completed
        Since:
        1.7
        MongoDB documentation
        Rename collection
        Since server release
        3.6
      • renameCollection

        Publisher<Void> renameCollection​(ClientSession clientSession,
                                         MongoNamespace newCollectionNamespace,
                                         RenameCollectionOptions options)
        Rename the collection with oldCollectionName to the newCollectionName.
        Parameters:
        clientSession - the client session with which to associate this operation
        newCollectionNamespace - the name the collection will be renamed to
        options - the options for renaming a collection
        Returns:
        an empty publisher that indicates when the operation has completed
        Since:
        1.7
        MongoDB documentation
        Rename collection
        Since server release
        3.6