Interface MongoDatabase


  • @ThreadSafe
    public interface MongoDatabase
    The MongoDatabase interface.

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

    Since:
    1.0
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      AggregatePublisher<org.bson.Document> aggregate​(ClientSession clientSession, java.util.List<? extends org.bson.conversions.Bson> pipeline)
      Runs an aggregation framework pipeline on the database for pipeline stages that do not require an underlying collection, such as $currentOp and $listLocalSessions.
      <TResult> AggregatePublisher<TResult> aggregate​(ClientSession clientSession, java.util.List<? extends org.bson.conversions.Bson> pipeline, java.lang.Class<TResult> resultClass)
      Runs an aggregation framework pipeline on the database for pipeline stages that do not require an underlying collection, such as $currentOp and $listLocalSessions.
      AggregatePublisher<org.bson.Document> aggregate​(java.util.List<? extends org.bson.conversions.Bson> pipeline)
      Runs an aggregation framework pipeline on the database for pipeline stages that do not require an underlying collection, such as $currentOp and $listLocalSessions.
      <TResult> AggregatePublisher<TResult> aggregate​(java.util.List<? extends org.bson.conversions.Bson> pipeline, java.lang.Class<TResult> resultClass)
      Runs an aggregation framework pipeline on the database for pipeline stages that do not require an underlying collection, such as $currentOp and $listLocalSessions.
      org.reactivestreams.Publisher<java.lang.Void> createCollection​(ClientSession clientSession, java.lang.String collectionName)
      Create a new collection with the given name.
      org.reactivestreams.Publisher<java.lang.Void> createCollection​(ClientSession clientSession, java.lang.String collectionName, com.mongodb.client.model.CreateCollectionOptions options)
      Create a new collection with the selected options
      org.reactivestreams.Publisher<java.lang.Void> createCollection​(java.lang.String collectionName)
      Create a new collection with the given name.
      org.reactivestreams.Publisher<java.lang.Void> createCollection​(java.lang.String collectionName, com.mongodb.client.model.CreateCollectionOptions options)
      Create a new collection with the selected options
      org.reactivestreams.Publisher<java.lang.Void> createView​(ClientSession clientSession, java.lang.String viewName, java.lang.String viewOn, java.util.List<? extends org.bson.conversions.Bson> pipeline)
      Creates a view with the given name, backing collection/view name, and aggregation pipeline that defines the view.
      org.reactivestreams.Publisher<java.lang.Void> createView​(ClientSession clientSession, java.lang.String viewName, java.lang.String viewOn, java.util.List<? extends org.bson.conversions.Bson> pipeline, com.mongodb.client.model.CreateViewOptions createViewOptions)
      Creates a view with the given name, backing collection/view name, aggregation pipeline, and options that defines the view.
      org.reactivestreams.Publisher<java.lang.Void> createView​(java.lang.String viewName, java.lang.String viewOn, java.util.List<? extends org.bson.conversions.Bson> pipeline)
      Creates a view with the given name, backing collection/view name, and aggregation pipeline that defines the view.
      org.reactivestreams.Publisher<java.lang.Void> createView​(java.lang.String viewName, java.lang.String viewOn, java.util.List<? extends org.bson.conversions.Bson> pipeline, com.mongodb.client.model.CreateViewOptions createViewOptions)
      Creates a view with the given name, backing collection/view name, aggregation pipeline, and options that defines the view.
      org.reactivestreams.Publisher<java.lang.Void> drop()
      Drops this database.
      org.reactivestreams.Publisher<java.lang.Void> drop​(ClientSession clientSession)
      Drops this database.
      org.bson.codecs.configuration.CodecRegistry getCodecRegistry()
      Get the codec registry for the MongoDatabase.
      MongoCollection<org.bson.Document> getCollection​(java.lang.String collectionName)
      Gets a collection.
      <TDocument>
      MongoCollection<TDocument>
      getCollection​(java.lang.String collectionName, java.lang.Class<TDocument> clazz)
      Gets a collection, with a specific default document class.
      java.lang.String getName()
      Gets the name of the database.
      com.mongodb.ReadConcern getReadConcern()
      Get the read concern for the MongoCollection.
      com.mongodb.ReadPreference getReadPreference()
      Get the read preference for the MongoDatabase.
      com.mongodb.WriteConcern getWriteConcern()
      Get the write concern for the MongoDatabase.
      org.reactivestreams.Publisher<java.lang.String> listCollectionNames()
      Gets the names of all the collections in this database.
      org.reactivestreams.Publisher<java.lang.String> listCollectionNames​(ClientSession clientSession)
      Gets the names of all the collections in this database.
      ListCollectionsPublisher<org.bson.Document> listCollections()
      Finds all the collections in this database.
      ListCollectionsPublisher<org.bson.Document> listCollections​(ClientSession clientSession)
      Finds all the collections in this database.
      <TResult> ListCollectionsPublisher<TResult> listCollections​(ClientSession clientSession, java.lang.Class<TResult> clazz)
      Finds all the collections in this database.
      <TResult> ListCollectionsPublisher<TResult> listCollections​(java.lang.Class<TResult> clazz)
      Finds all the collections in this database.
      org.reactivestreams.Publisher<org.bson.Document> runCommand​(ClientSession clientSession, org.bson.conversions.Bson command)
      Executes command in the context of the current database.
      org.reactivestreams.Publisher<org.bson.Document> runCommand​(ClientSession clientSession, org.bson.conversions.Bson command, com.mongodb.ReadPreference readPreference)
      Executes command in the context of the current database.
      <TResult> org.reactivestreams.Publisher<TResult> runCommand​(ClientSession clientSession, org.bson.conversions.Bson command, com.mongodb.ReadPreference readPreference, java.lang.Class<TResult> clazz)
      Executes command in the context of the current database.
      <TResult> org.reactivestreams.Publisher<TResult> runCommand​(ClientSession clientSession, org.bson.conversions.Bson command, java.lang.Class<TResult> clazz)
      Executes command in the context of the current database.
      org.reactivestreams.Publisher<org.bson.Document> runCommand​(org.bson.conversions.Bson command)
      Executes command in the context of the current database.
      org.reactivestreams.Publisher<org.bson.Document> runCommand​(org.bson.conversions.Bson command, com.mongodb.ReadPreference readPreference)
      Executes command in the context of the current database.
      <TResult> org.reactivestreams.Publisher<TResult> runCommand​(org.bson.conversions.Bson command, com.mongodb.ReadPreference readPreference, java.lang.Class<TResult> clazz)
      Executes command in the context of the current database.
      <TResult> org.reactivestreams.Publisher<TResult> runCommand​(org.bson.conversions.Bson command, java.lang.Class<TResult> clazz)
      Executes command in the context of the current database.
      ChangeStreamPublisher<org.bson.Document> watch()
      Creates a change stream for this database.
      ChangeStreamPublisher<org.bson.Document> watch​(ClientSession clientSession)
      Creates a change stream for this database.
      <TResult> ChangeStreamPublisher<TResult> watch​(ClientSession clientSession, java.lang.Class<TResult> resultClass)
      Creates a change stream for this database.
      ChangeStreamPublisher<org.bson.Document> watch​(ClientSession clientSession, java.util.List<? extends org.bson.conversions.Bson> pipeline)
      Creates a change stream for this database.
      <TResult> ChangeStreamPublisher<TResult> watch​(ClientSession clientSession, java.util.List<? extends org.bson.conversions.Bson> pipeline, java.lang.Class<TResult> resultClass)
      Creates a change stream for this database.
      <TResult> ChangeStreamPublisher<TResult> watch​(java.lang.Class<TResult> resultClass)
      Creates a change stream for this database.
      ChangeStreamPublisher<org.bson.Document> watch​(java.util.List<? extends org.bson.conversions.Bson> pipeline)
      Creates a change stream for this database.
      <TResult> ChangeStreamPublisher<TResult> watch​(java.util.List<? extends org.bson.conversions.Bson> pipeline, java.lang.Class<TResult> resultClass)
      Creates a change stream for this database.
      MongoDatabase withCodecRegistry​(org.bson.codecs.configuration.CodecRegistry codecRegistry)
      Create a new MongoDatabase instance with a different codec registry.
      MongoDatabase withReadConcern​(com.mongodb.ReadConcern readConcern)
      Create a new MongoDatabase instance with a different read concern.
      MongoDatabase withReadPreference​(com.mongodb.ReadPreference readPreference)
      Create a new MongoDatabase instance with a different read preference.
      MongoDatabase withWriteConcern​(com.mongodb.WriteConcern writeConcern)
      Create a new MongoDatabase instance with a different write concern.
    • Method Detail

      • getName

        java.lang.String getName()
        Gets the name of the database.
        Returns:
        the database name
      • getCodecRegistry

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

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

        com.mongodb.WriteConcern getWriteConcern()
        Get the write concern for the MongoDatabase.
        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
      • withCodecRegistry

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

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

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

        MongoDatabase withReadConcern​(com.mongodb.ReadConcern readConcern)
        Create a new MongoDatabase instance with a different read concern.
        Parameters:
        readConcern - the new ReadConcern for the collection
        Returns:
        a new MongoDatabase instance with the different ReadConcern
        Since:
        1.2
        Since server release
        3.2
      • getCollection

        MongoCollection<org.bson.Document> getCollection​(java.lang.String collectionName)
        Gets a collection.
        Parameters:
        collectionName - the name of the collection to return
        Returns:
        the collection
      • getCollection

        <TDocument> MongoCollection<TDocument> getCollection​(java.lang.String collectionName,
                                                             java.lang.Class<TDocument> clazz)
        Gets a collection, with a specific default document class.
        Type Parameters:
        TDocument - the type of the class to use instead of Document.
        Parameters:
        collectionName - the name of the collection to return
        clazz - the default class to cast any documents returned from the database into.
        Returns:
        the collection
      • runCommand

        org.reactivestreams.Publisher<org.bson.Document> runCommand​(org.bson.conversions.Bson command)
        Executes command in the context of the current database.
        Parameters:
        command - the command to be run
        Returns:
        a publisher containing the command result
      • runCommand

        org.reactivestreams.Publisher<org.bson.Document> runCommand​(org.bson.conversions.Bson command,
                                                                    com.mongodb.ReadPreference readPreference)
        Executes command in the context of the current database.
        Parameters:
        command - the command to be run
        readPreference - the ReadPreference to be used when executing the command
        Returns:
        a publisher containing the command result
      • runCommand

        <TResult> org.reactivestreams.Publisher<TResult> runCommand​(org.bson.conversions.Bson command,
                                                                    java.lang.Class<TResult> clazz)
        Executes command in the context of the current database.
        Type Parameters:
        TResult - the type of the class to use instead of Document.
        Parameters:
        command - the command to be run
        clazz - the default class to cast any documents returned from the database into.
        Returns:
        a publisher containing the command result
      • runCommand

        <TResult> org.reactivestreams.Publisher<TResult> runCommand​(org.bson.conversions.Bson command,
                                                                    com.mongodb.ReadPreference readPreference,
                                                                    java.lang.Class<TResult> clazz)
        Executes command in the context of the current database.
        Type Parameters:
        TResult - the type of the class to use instead of Document.
        Parameters:
        command - the command to be run
        readPreference - the ReadPreference to be used when executing the command
        clazz - the default class to cast any documents returned from the database into.
        Returns:
        a publisher containing the command result
      • runCommand

        org.reactivestreams.Publisher<org.bson.Document> runCommand​(ClientSession clientSession,
                                                                    org.bson.conversions.Bson command)
        Executes command in the context of the current database.
        Parameters:
        clientSession - the client session with which to associate this operation
        command - the command to be run
        Returns:
        a publisher containing the command result
        Since:
        1.7
        Since server release
        3.6
      • runCommand

        org.reactivestreams.Publisher<org.bson.Document> runCommand​(ClientSession clientSession,
                                                                    org.bson.conversions.Bson command,
                                                                    com.mongodb.ReadPreference readPreference)
        Executes command in the context of the current database.
        Parameters:
        clientSession - the client session with which to associate this operation
        command - the command to be run
        readPreference - the ReadPreference to be used when executing the command
        Returns:
        a publisher containing the command result
        Since:
        1.7
        Since server release
        3.6
      • runCommand

        <TResult> org.reactivestreams.Publisher<TResult> runCommand​(ClientSession clientSession,
                                                                    org.bson.conversions.Bson command,
                                                                    java.lang.Class<TResult> clazz)
        Executes command in the context of the current database.
        Type Parameters:
        TResult - the type of the class to use instead of Document.
        Parameters:
        clientSession - the client session with which to associate this operation
        command - the command to be run
        clazz - the default class to cast any documents returned from the database into.
        Returns:
        a publisher containing the command result
        Since:
        1.7
        Since server release
        3.6
      • runCommand

        <TResult> org.reactivestreams.Publisher<TResult> runCommand​(ClientSession clientSession,
                                                                    org.bson.conversions.Bson command,
                                                                    com.mongodb.ReadPreference readPreference,
                                                                    java.lang.Class<TResult> clazz)
        Executes command in the context of the current database.
        Type Parameters:
        TResult - the type of the class to use instead of Document.
        Parameters:
        clientSession - the client session with which to associate this operation
        command - the command to be run
        readPreference - the ReadPreference to be used when executing the command
        clazz - the default class to cast any documents returned from the database into.
        Returns:
        a publisher containing the command result
        Since:
        1.7
        Since server release
        3.6
      • drop

        org.reactivestreams.Publisher<java.lang.Void> drop()
        Drops this database.
        Returns:
        a publisher identifying when the database has been dropped
        MongoDB documentation
        Drop database
      • drop

        org.reactivestreams.Publisher<java.lang.Void> drop​(ClientSession clientSession)
        Drops this database.
        Parameters:
        clientSession - the client session with which to associate this operation
        Returns:
        a publisher identifying when the database has been dropped
        Since:
        1.7
        MongoDB documentation
        Drop database
        Since server release
        3.6
      • listCollectionNames

        org.reactivestreams.Publisher<java.lang.String> listCollectionNames()
        Gets the names of all the collections in this database.
        Returns:
        a publisher with all the names of all the collections in this database
      • listCollectionNames

        org.reactivestreams.Publisher<java.lang.String> listCollectionNames​(ClientSession clientSession)
        Gets the names of all the collections in this database.
        Parameters:
        clientSession - the client session with which to associate this operation
        Returns:
        a publisher with all the names of all the collections in this database
        Since:
        1.7
        Since server release
        3.6
      • listCollections

        ListCollectionsPublisher<org.bson.Document> listCollections()
        Finds all the collections in this database.
        Returns:
        the fluent list collections interface
        MongoDB documentation
        listCollections
      • listCollections

        <TResult> ListCollectionsPublisher<TResult> listCollections​(java.lang.Class<TResult> clazz)
        Finds all the collections in this database.
        Type Parameters:
        TResult - the target document type of the iterable.
        Parameters:
        clazz - the class to decode each document into
        Returns:
        the fluent list collections interface
        MongoDB documentation
        listCollections
      • listCollections

        ListCollectionsPublisher<org.bson.Document> listCollections​(ClientSession clientSession)
        Finds all the collections in this database.
        Parameters:
        clientSession - the client session with which to associate this operation
        Returns:
        the fluent list collections interface
        Since:
        1.7
        MongoDB documentation
        listCollections
        Since server release
        3.6
      • listCollections

        <TResult> ListCollectionsPublisher<TResult> listCollections​(ClientSession clientSession,
                                                                    java.lang.Class<TResult> clazz)
        Finds all the collections in this database.
        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 collections interface
        Since:
        1.7
        MongoDB documentation
        listCollections
        Since server release
        3.6
      • createCollection

        org.reactivestreams.Publisher<java.lang.Void> createCollection​(java.lang.String collectionName)
        Create a new collection with the given name.
        Parameters:
        collectionName - the name for the new collection to create
        Returns:
        a publisher identifying when the collection has been created
        MongoDB documentation
        Create Command
      • createCollection

        org.reactivestreams.Publisher<java.lang.Void> createCollection​(java.lang.String collectionName,
                                                                       com.mongodb.client.model.CreateCollectionOptions options)
        Create a new collection with the selected options
        Parameters:
        collectionName - the name for the new collection to create
        options - various options for creating the collection
        Returns:
        a publisher identifying when the collection has been created
        MongoDB documentation
        Create Command
      • createCollection

        org.reactivestreams.Publisher<java.lang.Void> createCollection​(ClientSession clientSession,
                                                                       java.lang.String collectionName)
        Create a new collection with the given name.
        Parameters:
        clientSession - the client session with which to associate this operation
        collectionName - the name for the new collection to create
        Returns:
        a publisher identifying when the collection has been created
        Since:
        1.7
        MongoDB documentation
        Create Command
        Since server release
        3.6
      • createCollection

        org.reactivestreams.Publisher<java.lang.Void> createCollection​(ClientSession clientSession,
                                                                       java.lang.String collectionName,
                                                                       com.mongodb.client.model.CreateCollectionOptions options)
        Create a new collection with the selected options
        Parameters:
        clientSession - the client session with which to associate this operation
        collectionName - the name for the new collection to create
        options - various options for creating the collection
        Returns:
        a publisher identifying when the collection has been created
        Since:
        1.7
        MongoDB documentation
        Create Command
        Since server release
        3.6
      • createView

        org.reactivestreams.Publisher<java.lang.Void> createView​(java.lang.String viewName,
                                                                 java.lang.String viewOn,
                                                                 java.util.List<? extends org.bson.conversions.Bson> pipeline)
        Creates a view with the given name, backing collection/view name, and aggregation pipeline that defines the view.
        Parameters:
        viewName - the name of the view to create
        viewOn - the backing collection/view for the view
        pipeline - the pipeline that defines the view
        Returns:
        an observable identifying when the collection view has been created
        Since:
        1.3
        MongoDB documentation
        Create Command
        Since server release
        3.4
      • createView

        org.reactivestreams.Publisher<java.lang.Void> createView​(java.lang.String viewName,
                                                                 java.lang.String viewOn,
                                                                 java.util.List<? extends org.bson.conversions.Bson> pipeline,
                                                                 com.mongodb.client.model.CreateViewOptions createViewOptions)
        Creates a view with the given name, backing collection/view name, aggregation pipeline, and options that defines the view.
        Parameters:
        viewName - the name of the view to create
        viewOn - the backing collection/view for the view
        pipeline - the pipeline that defines the view
        createViewOptions - various options for creating the view
        Returns:
        an observable identifying when the collection view has been created
        Since:
        1.3
        MongoDB documentation
        Create Command
        Since server release
        3.4
      • createView

        org.reactivestreams.Publisher<java.lang.Void> createView​(ClientSession clientSession,
                                                                 java.lang.String viewName,
                                                                 java.lang.String viewOn,
                                                                 java.util.List<? extends org.bson.conversions.Bson> pipeline)
        Creates a view with the given name, backing collection/view name, and aggregation pipeline that defines the view.
        Parameters:
        clientSession - the client session with which to associate this operation
        viewName - the name of the view to create
        viewOn - the backing collection/view for the view
        pipeline - the pipeline that defines the view
        Returns:
        an observable identifying when the collection view has been created
        Since:
        1.7
        MongoDB documentation
        Create Command
        Since server release
        3.6
      • createView

        org.reactivestreams.Publisher<java.lang.Void> createView​(ClientSession clientSession,
                                                                 java.lang.String viewName,
                                                                 java.lang.String viewOn,
                                                                 java.util.List<? extends org.bson.conversions.Bson> pipeline,
                                                                 com.mongodb.client.model.CreateViewOptions createViewOptions)
        Creates a view with the given name, backing collection/view name, aggregation pipeline, and options that defines the view.
        Parameters:
        clientSession - the client session with which to associate this operation
        viewName - the name of the view to create
        viewOn - the backing collection/view for the view
        pipeline - the pipeline that defines the view
        createViewOptions - various options for creating the view
        Returns:
        an observable identifying when the collection view has been created
        Since:
        1.7
        MongoDB documentation
        Create Command
        Since server release
        3.6
      • watch

        ChangeStreamPublisher<org.bson.Document> watch()
        Creates a change stream for this database.
        Returns:
        the change stream iterable
        Since:
        1.9
        MongoDB documentation
        Change Streams
        Since server release
        4.0
      • watch

        <TResult> ChangeStreamPublisher<TResult> watch​(java.lang.Class<TResult> resultClass)
        Creates a change stream for this database.
        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.9
        MongoDB documentation
        Change Streams
        Since server release
        4.0
      • watch

        ChangeStreamPublisher<org.bson.Document> watch​(java.util.List<? extends org.bson.conversions.Bson> pipeline)
        Creates a change stream for this database.
        Parameters:
        pipeline - the aggregation pipeline to apply to the change stream.
        Returns:
        the change stream iterable
        Since:
        1.9
        MongoDB documentation
        Change Streams
        Since server release
        4.0
      • watch

        <TResult> ChangeStreamPublisher<TResult> watch​(java.util.List<? extends org.bson.conversions.Bson> pipeline,
                                                       java.lang.Class<TResult> resultClass)
        Creates a change stream for this database.
        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.9
        MongoDB documentation
        Change Streams
        Since server release
        4.0
      • watch

        ChangeStreamPublisher<org.bson.Document> watch​(ClientSession clientSession)
        Creates a change stream for this database.
        Parameters:
        clientSession - the client session with which to associate this operation
        Returns:
        the change stream iterable
        Since:
        1.9
        MongoDB documentation
        Change Streams
        Since server release
        4.0
      • watch

        <TResult> ChangeStreamPublisher<TResult> watch​(ClientSession clientSession,
                                                       java.lang.Class<TResult> resultClass)
        Creates a change stream for this database.
        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.9
        MongoDB documentation
        Change Streams
        Since server release
        4.0
      • watch

        ChangeStreamPublisher<org.bson.Document> watch​(ClientSession clientSession,
                                                       java.util.List<? extends org.bson.conversions.Bson> pipeline)
        Creates a change stream for this database.
        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.9
        MongoDB documentation
        Change Streams
        Since server release
        4.0
      • watch

        <TResult> ChangeStreamPublisher<TResult> watch​(ClientSession clientSession,
                                                       java.util.List<? extends org.bson.conversions.Bson> pipeline,
                                                       java.lang.Class<TResult> resultClass)
        Creates a change stream for this database.
        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.9
        MongoDB documentation
        Change Streams
        Since server release
        4.0
      • aggregate

        AggregatePublisher<org.bson.Document> aggregate​(java.util.List<? extends org.bson.conversions.Bson> pipeline)
        Runs an aggregation framework pipeline on the database for pipeline stages that do not require an underlying collection, such as $currentOp and $listLocalSessions.
        Parameters:
        pipeline - the aggregation pipeline
        Returns:
        an iterable containing the result of the aggregation operation
        Since:
        1.11
        MongoDB documentation
        Aggregate Command
        Since server release
        3.6
      • aggregate

        <TResult> AggregatePublisher<TResult> aggregate​(java.util.List<? extends org.bson.conversions.Bson> pipeline,
                                                        java.lang.Class<TResult> resultClass)
        Runs an aggregation framework pipeline on the database for pipeline stages that do not require an underlying collection, such as $currentOp and $listLocalSessions.
        Type Parameters:
        TResult - the target document type of the iterable.
        Parameters:
        pipeline - the aggregation pipeline
        resultClass - the class to decode each document into
        Returns:
        an iterable containing the result of the aggregation operation
        Since:
        1.11
        MongoDB documentation
        Aggregate Command
        Since server release
        3.6
      • aggregate

        AggregatePublisher<org.bson.Document> aggregate​(ClientSession clientSession,
                                                        java.util.List<? extends org.bson.conversions.Bson> pipeline)
        Runs an aggregation framework pipeline on the database for pipeline stages that do not require an underlying collection, such as $currentOp and $listLocalSessions.
        Parameters:
        clientSession - the client session with which to associate this operation
        pipeline - the aggregation pipeline
        Returns:
        an iterable containing the result of the aggregation operation
        Since:
        1.11
        MongoDB documentation
        Aggregate Command
        Since server release
        3.6
      • aggregate

        <TResult> AggregatePublisher<TResult> aggregate​(ClientSession clientSession,
                                                        java.util.List<? extends org.bson.conversions.Bson> pipeline,
                                                        java.lang.Class<TResult> resultClass)
        Runs an aggregation framework pipeline on the database for pipeline stages that do not require an underlying collection, such as $currentOp and $listLocalSessions.
        Type Parameters:
        TResult - the target document type of the iterable.
        Parameters:
        clientSession - the client session with which to associate this operation
        pipeline - the aggregation pipeline
        resultClass - the class to decode each document into
        Returns:
        an iterable containing the result of the aggregation operation
        Since:
        1.11
        MongoDB documentation
        Aggregate Command
        Since server release
        3.6