Class MongoDbMethods


  • public final class MongoDbMethods
    extends Object
    • Constructor Detail

      • MongoDbMethods

        @Autowired
        MongoDbMethods​(io.toro.martini.database.DataSourceManager manager)
    • Method Detail

      • setDataSourceManager

        static void setDataSourceManager​(io.toro.martini.database.DataSourceManager manager)
      • getGloopCodecRegistry

        public static org.bson.codecs.configuration.CodecRegistry getGloopCodecRegistry()
        Returns a codec registry which contains the Codec for Gloop Models. If you're creating your own Mongo Client for use with Gloop, this registry must be added. Example:
             import static org.bson.codecs.configuration.CodecRegistries.fromProviders;
             import static org.bson.codecs.configuration.CodecRegistries.fromRegistries;
        
             ...
        
        
             CodecRegistry pojoCodecRegistry = fromRegistries(
             MongoClient.getDefaultCodecRegistry(), MongoDbMethods.getGloopCodecRegistry(), // <-- added gloop codec here
                 fromProviders( PojoCodecProvider.builder().automatic( true ).build() ) );
             return new MongoClient( host, MongoClientOptions.builder().codecRegistry( pojoCodecRegistry ).build() );
         
        Since:
        1.0
      • find

        @GloopObjectParameter("output{\n  mongoFindCursor[]*{\n  }\n}")
        public static GloopModel find​(@NotNull
                                      @NotNull String connectionName,
                                      @NotNull
                                      @NotNull String databaseName,
                                      @NotNull
                                      @NotNull String collection,
                                      String filter,
                                      String projection,
                                      ClientSession clientSession,
                                      @GloopParameter(defaultValue="false")
                                      boolean closeClient,
                                      GloopExecutionContext context)
        Open a Mongo Input cursor that will use the Gloop codec to convert records in MongoDB to Gloop Models
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the databaseName name
        collection - the collection name
        filter - selection filter using query operators.
        projection - specifies the fields to return in the documents that match the query filter
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        closeClient - boolean stating whether the cursor will close the mongoDb client after it has been exhausted
        context - the Gloop Execution Context
        Since:
        1.0
      • find

        @GloopObjectParameter("output{\n  mongoFindCursor[]*{\n  }\n}")
        public static GloopModel find​(@NotNull
                                      @NotNull MongoClient client,
                                      @NotNull
                                      @NotNull String databaseName,
                                      @NotNull
                                      @NotNull String collection,
                                      String filter,
                                      String projection,
                                      ClientSession clientSession,
                                      @GloopParameter(defaultValue="false")
                                      boolean closeClient,
                                      GloopExecutionContext context)
        Open a Mongo Input cursor that will use the Gloop codec to convert records in MongoDB to Gloop Models
        Parameters:
        client - a pre-configured Mongo client, which must have the GloopCodec included. See here.
        databaseName - the databaseName name
        collection - the collection name
        filter - selection filter using query operators.
        projection - specifies the fields to return in the documents that match the query filter
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        closeClient - boolean stating whether the cursor will close the mongoDb client after it has been exhausted
        context - the Gloop Execution Context
        Since:
        1.0
      • findFirst

        @GloopObjectParameter("output{\n  mongoResult*{\n  }\n}")
        public static GloopModel findFirst​(@NotNull
                                           @NotNull String connectionName,
                                           @NotNull
                                           @NotNull String databaseName,
                                           @NotNull
                                           @NotNull String collection,
                                           String filter,
                                           String projection,
                                           ClientSession clientSession,
                                           @GloopParameter(defaultValue="false")
                                           boolean closeClient,
                                           GloopExecutionContext context)
        Return a gloop model, which is the first result of the given query
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the databaseName name
        collection - the collection name
        filter - selection filter using query operators.
        projection - specifies the fields to return in the documents that match the query filter
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        closeClient - boolean stating whether the cursor will close the mongoDb client after it has been exhausted
        context - the Gloop Execution Context
        Returns:
        GloopModel the first item or null.
        Since:
        1.0
      • findFirst

        @GloopObjectParameter("output{\n  mongoResult*{\n  }\n}")
        public static GloopModel findFirst​(@NotNull
                                           @NotNull MongoClient client,
                                           @NotNull
                                           @NotNull String databaseName,
                                           @NotNull
                                           @NotNull String collection,
                                           String filter,
                                           String projection,
                                           ClientSession clientSession,
                                           @GloopParameter(defaultValue="false")
                                           boolean closeClient,
                                           GloopExecutionContext context)
        Return a gloop model, which is the first result of the given query
        Parameters:
        client - a pre-configured Mongo client, which must have the GloopCodec included. See here.
        databaseName - the databaseName name
        collection - the collection name
        filter - selection filter using query operators.
        projection - specifies the fields to return in the documents that match the query filter
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        closeClient - boolean stating whether the cursor will close the mongoDb client after it has been exhausted
        context - the Gloop Execution Context
        Returns:
        GloopModel the first item or null.
        Since:
        1.0
      • insertMany

        @GloopObjectParameter("mongoInsertCursor{\n  mongoInsertCursor[]*{\n  }\n}")
        public static GloopCursor insertMany​(@NotNull
                                             @NotNull String connectionName,
                                             @NotNull
                                             @NotNull String databaseName,
                                             @NotNull
                                             @NotNull String collection,
                                             @GloopParameter(defaultValue="10000")
                                             int batchSize,
                                             ClientSession clientSession,
                                             @GloopParameter(defaultValue="false")
                                             boolean closeClient,
                                             GloopExecutionContext context)
        Open a Mongo Output cursor that will use the Gloop Codec to convert Gloop Models to Mongo DB documents, allowing Gloop to write records.
        Parameters:
        connectionName - the name of the connection
        databaseName - the databaseName name
        collection - the collection name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        closeClient - boolean stating whether the cursor will close the mongoDb client after it has been exhausted
        context - the Gloop Execution Context
        Since:
        1.0
      • insertMany

        public static void insertMany​(@NotNull
                                      @NotNull String connectionName,
                                      @NotNull
                                      @NotNull String databaseName,
                                      @NotNull
                                      @NotNull String collectionName,
                                      ClientSession clientSession,
                                      @NotNull
                                      @NotNull List<GloopModel> documents,
                                      @GloopParameter(defaultValue="false")
                                      boolean ordered,
                                      Boolean bypassDocumentValidation)
        Inserts one or more documents. A call to this method is equivalent to a call to the bulkWrite method

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

        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        documents - the documents to insert
        Throws:
        DuplicateKeyException - if the write failed to a duplicate unique key
        WriteConcernException - if the write failed due being unable to fulfil the write concern
        MongoException - if the write failed due some other failure
        Since:
        1.0
      • getUsedDatabases

        public static org.bson.Document getUsedDatabases​(@NotNull
                                                         @NotNull String connectionName)
        Returns the list of databases used by the driver since this Mongo instance was created. This may include DBs that exist in the client but not yet on the server.
        Parameters:
        connectionName - the name of the mongo db connection
        Returns:
        a collection of database objects
        Since:
        1.0
      • dropDatabase

        public static void dropDatabase​(@NotNull
                                        @NotNull String connectionName,
                                        @NotNull
                                        @NotNull String databaseName)
        Drops the database if it exists.
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - name of database to drop
        Throws:
        MongoException - if the operation fails
        Since:
        1.0
      • fsync

        public static org.bson.Document fsync​(@NotNull
                                              @NotNull String connectionName,
                                              @GloopParameter(defaultValue="false")
                                              boolean async)
        Forces the master server to fsync the RAM data to disk. This is done automatically by the server at intervals, but can be forced for better reliability.
        Parameters:
        connectionName - the name of the mongo db connection
        async - if true, the fsync will be done asynchronously on the server.
        Returns:
        result of the command execution
        Throws:
        MongoException - if there's a failure
        Since:
        1.0
      • fsyncAndLock

        public static org.bson.Document fsyncAndLock​(@NotNull
                                                     @NotNull String connectionName)
        Forces the master server to fsync the RAM data to disk, then lock all writes. The database will be read-only after this command returns.
        Parameters:
        connectionName - the name of the mongo db connection
        Returns:
        result of the command execution
        Throws:
        MongoException - if there's a failure
        Since:
        1.0
      • unlock

        public static org.bson.Document unlock​(@NotNull
                                               @NotNull String connectionName)
        Unlocks the database, allowing the write operations to go through. This command may be asynchronous on the server, which means there may be a small delay before the database becomes writable.
        Parameters:
        connectionName - the name of the mongo db connection
        Returns:
        DBObject in the following form {"ok": 1,"info": "unlock completed"}
        Throws:
        MongoException - if there's a failure
        Since:
        1.0
      • isLocked

        public static boolean isLocked​(@NotNull
                                       @NotNull String connectionName)
        Returns true if the database is locked (read-only), false otherwise.
        Parameters:
        connectionName - the name of the mongo db connection
        Returns:
        result of the command execution
        Throws:
        MongoException - if the operation fails
        Since:
        1.0
      • connectionToString

        public String connectionToString​(@NotNull
                                         @NotNull String connectionName)
        Returns a string representation of the mongo client object.
        Parameters:
        connectionName - the name of the mongo db connection
        Returns:
        result of the command execution
        Throws:
        MongoException - if the operation fails
        Since:
        1.0
      • connection

        public static io.toro.martini.database.MongoDbDataSource connection​(String connectionName)
        Return mongo datasource object
        Parameters:
        connectionName - the name of the saved database connection in Martini
        Returns:
        datasource
      • getConnectPoint

        @Nullable
        public static String getConnectPoint​(@NotNull
                                             @NotNull String connectionName)
        Gets a String representation of current connection point, i.e. master.
        Parameters:
        connectionName - the name of the mongo db connection
        Returns:
        server address in a host:port form
        Since:
        1.0
      • getMongoClientOptions

        public static org.bson.Document getMongoClientOptions​(@NotNull
                                                              @NotNull String connectionName)
        Gets the options that this client uses to connect to server.
        Parameters:
        connectionName - the name of the mongo db connection
        Returns:
        the options
        Since:
        1.0
      • getCredentialsList

        public static org.bson.Document getCredentialsList​(@NotNull
                                                           @NotNull String connectionName)
        Gets the list of credentials that this client authenticates all connections with
        Parameters:
        connectionName - the name of the mongo db connection
        Returns:
        the list of credentials
        Since:
        1.0
      • startSession

        public static ClientSession startSession​(@NotNull
                                                 @NotNull String connectionName,
                                                 ClientSessionOptions options)
        Creates a client session.

        Note: A ClientSession instance can not be used concurrently in multiple operations.

        Parameters:
        connectionName - the name of the mongo db connection
        options - the options for the client session. If null, default options will be used
        Returns:
        the client session
        Since:
        1.0
      • startSession

        @GloopParameter(name="$clientSession")
        public static ClientSession startSession​(@NotNull
                                                 @NotNull String connectionName,
                                                 @GloopObjectParameter("clientSessionOptions#io.toro.martini.mongodb.ClientSessionOptions{\n}\n")
                                                 GloopModel clientSessionOptions)
        Creates a client session.

        Note: A ClientSession instance can not be used concurrently in multiple operations.

        Parameters:
        connectionName - the name of the mongo db connection
        clientSessionOptions - the options for the client session. If null, default options will be used
        Returns:
        the client session
        Since:
        1.0
      • startTransaction

        public static void startTransaction​(@NotNull
                                            @NotNull ClientSession clientSession,
                                            TransactionOptions transactionOptions)
        Start a transaction in the context of this session with the given transaction options. A transaction can not be started if there is already an active transaction on this session.
        Parameters:
        clientSession - the client session
        transactionOptions - the options to apply to the transaction
        Since:
        1.0
      • startTransaction

        public static void startTransaction​(@NotNull
                                            @NotNull ClientSession clientSession,
                                            @GloopObjectParameter("transactionOptions#io.toro.martini.mongodb.TransactionOptions{\n}\n")
                                            GloopModel transactionOptions)
        Start a transaction in the context of this session with the given transaction options. A transaction can not be started if there is already an active transaction on this session.
        Parameters:
        clientSession - the client session
        transactionOptions - the options to apply to the transaction
        Since:
        1.0
      • hasActiveTransaction

        public static boolean hasActiveTransaction​(@NotNull
                                                   @NotNull ClientSession clientSession)
        Returns true if there is an active transaction on this session, and false otherwise
        Parameters:
        clientSession - the client session
        Returns:
        true if there is an active transaction on this session
        Since:
        1.0
      • getTransactionOptions

        public static TransactionOptions getTransactionOptions​(@NotNull
                                                               @NotNull ClientSession clientSession)
        Gets the transaction options. Only call this method of the session has an active transaction
        Parameters:
        clientSession - the client session*
        Returns:
        the transaction options
        Since:
        1.0
      • commitTransaction

        public static void commitTransaction​(@NotNull
                                             @NotNull ClientSession clientSession)
        Commit a transaction in the context of this session. A transaction can only be committed if one has first been started.
        Parameters:
        clientSession - the client session*
        Since:
        1.0
      • abortTransaction

        public static void abortTransaction​(@NotNull
                                            @NotNull ClientSession clientSession)
        Abort a transaction in the context of this session. A transaction can only be aborted if one has first been started.
        Parameters:
        clientSession - the client session
        Since:
        1.0
      • listDatabaseNames

        public static Collection<String> listDatabaseNames​(@NotNull
                                                           @NotNull String connectionName,
                                                           ClientSession clientSession)
        Get a list of the database names
        Parameters:
        connectionName - the name of the mongo db connection
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        Returns:
        an iterable containing all the names of all the databases
        Since:
        1.0
      • listDatabases

        @GloopObjectParameter("output{\n  mongoDbDatabases#io.toro.martini.mongodb.Database[]{\n  }\n}")
        public static GloopModel listDatabases​(@NotNull
                                               @NotNull String connectionName,
                                               ClientSession clientSession)
        Gets the list of databases
        Parameters:
        connectionName - the name of the mongo db connection
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        Returns:
        the list databases iterable interface
        Since:
        1.0
      • runCommand

        public static GloopModel runCommand​(@NotNull
                                            @NotNull String connectionName,
                                            @NotNull
                                            @NotNull String databaseName,
                                            ClientSession clientSession,
                                            @NotNull
                                            @NotNull org.bson.conversions.Bson command)
        Executes the given command in the context of the current database with a read preference of ReadPreference.primary().
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        command - the command to be run
        Returns:
        the command result
        Since:
        1.0
      • runCommand

        public static GloopModel runCommand​(@NotNull
                                            @NotNull String connectionName,
                                            @NotNull
                                            @NotNull String databaseName,
                                            ClientSession clientSession,
                                            @NotNull
                                            @NotNull String query)
        Executes the given command in the context of the current database with a read preference of ReadPreference.primary().
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        query - the command to be run
        Returns:
        the command result
        Since:
        1.0
      • drop

        public static void drop​(@NotNull
                                @NotNull String connectionName,
                                @NotNull
                                @NotNull String databaseName,
                                ClientSession clientSession)
        Drops this database.
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        Since:
        1.0
      • drop

        public static void drop​(@NotNull
                                @NotNull String connectionName,
                                @NotNull
                                @NotNull String databaseName,
                                @NotNull
                                @NotNull String collectionName,
                                ClientSession clientSession)
        Drops this collection from the Database.
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        Since:
        1.0
      • listCollectionNames

        public static List<String> listCollectionNames​(@NotNull
                                                       @NotNull String connectionName,
                                                       @NotNull
                                                       @NotNull String databaseName,
                                                       ClientSession clientSession)
        Gets the names of all the collections in this database.
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        Returns:
        an iterable containing all the names of all the collections in this database
        Since:
        1.0
      • listCollections

        @GloopObjectParameter("output{\n  mongoDbCollections#io.toro.martini.mongodb.Collection[]{\n  }\n}")
        public static GloopModel listCollections​(@NotNull
                                                 @NotNull String connectionName,
                                                 @NotNull
                                                 @NotNull String databaseName,
                                                 ClientSession clientSession)
        Finds all the collections in this database.
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        Returns:
        the list collections iterable interface
        Since:
        1.0
      • createDatabaseAndCollection

        public static void createDatabaseAndCollection​(@NotNull
                                                       @NotNull String connectionName,
                                                       @NotNull
                                                       @NotNull String databaseName,
                                                       @NotNull
                                                       @NotNull String collectionName,
                                                       ClientSession clientSession)
        Create a new collection with the given name.
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name, will be created if it doesn't already exist
        collectionName - the name for the new collection to create
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        Since:
        1.0
      • dropCollection

        public static void dropCollection​(@NotNull
                                          @NotNull String connectionName,
                                          @NotNull
                                          @NotNull String databaseName,
                                          @NotNull
                                          @NotNull String collectionName,
                                          ClientSession clientSession)
        Drop a collection with the given name.
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        collectionName - the name for the collection to drop
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        Since:
        1.0
      • createView

        public static void createView​(@NotNull
                                      @NotNull String connectionName,
                                      @NotNull
                                      @NotNull String databaseName,
                                      @NotNull
                                      @NotNull String viewName,
                                      String viewOn,
                                      List<? extends org.bson.conversions.Bson> pipeline,
                                      ClientSession clientSession,
                                      @NotNull
                                      @NotNull CreateViewOptions createViewOptions)
        Creates a view with the given name, backing collection/view name, and aggregation pipeline that defines the view.
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        viewName - the name of the view to create
        viewOn - the backing collection/view for the view
        pipeline - the pipeline that defines the view
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        createViewOptions - create view options
        Since:
        1.0
      • countDocuments

        public static long countDocuments​(@NotNull
                                          @NotNull String connectionName,
                                          @NotNull
                                          @NotNull String databaseName,
                                          @NotNull
                                          @NotNull String collectionName,
                                          ClientSession clientSession,
                                          org.bson.conversions.Bson filter)
        Counts the number of documents in the collection according to the given options.

        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:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        collectionName - the collection name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        filter - the query filter
        Returns:
        the number of documents in the collection
        Since:
        1.0
      • countDocuments

        public static long countDocuments​(@NotNull
                                          @NotNull String connectionName,
                                          @NotNull
                                          @NotNull String databaseName,
                                          @NotNull
                                          @NotNull String collectionName,
                                          String query,
                                          ClientSession clientSession)
        Counts the number of documents in the collection according to the given options.
        Parameters:
        query - leave null to count all documents in the collection

        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 |
                  +-------------+--------------------------------+
                 
        connectionName - the name of the mongo db connection
        databaseName - the database name
        collectionName - the collection name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        Returns:
        the number of documents in the collection
        Since:
        1.0
      • estimatedDocumentCount

        public static long estimatedDocumentCount​(@NotNull
                                                  @NotNull String connectionName,
                                                  @NotNull
                                                  @NotNull String databaseName,
                                                  @NotNull
                                                  @NotNull String collectionName,
                                                  @NotNull
                                                  @javax.validation.constraints.NotNull long maxTime)
        Gets an estimate of the count of documents in a collection using collection metadata.
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        collectionName - the collection name
        maxTime - The maximum time to wait in milliseconds. Set to a number <= 0 for no time limit.
        Returns:
        the number of documents in the collection
        Since:
        1.0
      • distinct

        @GloopObjectParameter("mongoDbDistinctValuesCursor[]:object")
        public static <T> GloopCursor distinct​(@NotNull
                                               @NotNull String connectionName,
                                               @NotNull
                                               @NotNull String databaseName,
                                               @NotNull
                                               @NotNull String collectionName,
                                               @NotNull
                                               @NotNull String fieldName,
                                               org.bson.conversions.Bson filter,
                                               ClientSession clientSession,
                                               @NotNull
                                               @NotNull Class<T> resultClass,
                                               @GloopParameter(defaultValue="false")
                                               boolean closeClient,
                                               GloopExecutionContext context)
        Gets the distinct values of the specified field name.
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        collectionName - the collection name
        fieldName - the field name
        resultClass - the class to cast any distinct items into.
        filter - the filter
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        closeClient - boolean stating whether the cursor will close the mongoDb client after it has been exhausted
        Returns:
        an iterable of distinct values
        Since:
        1.0
      • distinct

        @GloopObjectParameter("distinctValuesCursor[]:object")
        public static <T> GloopCursor distinct​(@NotNull
                                               @NotNull String connectionName,
                                               @NotNull
                                               @NotNull String databaseName,
                                               @NotNull
                                               @NotNull String collectionName,
                                               @NotNull
                                               @NotNull String fieldName,
                                               @NotNull
                                               @NotNull String query,
                                               ClientSession clientSession,
                                               Class<T> resultClass,
                                               @GloopParameter(defaultValue="false")
                                               boolean closeClient,
                                               GloopExecutionContext context)
        Gets the distinct values of the specified field name.
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        collectionName - the collection name
        fieldName - the field name
        query - the query
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        resultClass - the class to cast any distinct items into.
        closeClient - boolean stating whether the cursor will close the mongoDb client after it has been exhausted
        Returns:
        an iterable of distinct values
        Since:
        1.0
      • aggregate

        @GloopObjectParameter("mongoAggregateCursor[]:object")
        public static GloopCursor aggregate​(@NotNull
                                            @NotNull String connectionName,
                                            @NotNull
                                            @NotNull String databaseName,
                                            @NotNull
                                            @NotNull String collectionName,
                                            List<? extends org.bson.conversions.Bson> pipeline,
                                            ClientSession clientSession,
                                            @GloopParameter(defaultValue="false")
                                            boolean closeClient,
                                            GloopExecutionContext context)
        Aggregates documents according to the specified aggregation pipeline.
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        collectionName - the collection name
        pipeline - the aggregation pipeline
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        closeClient - boolean stating whether the cursor will close the mongoDb client after it has been exhausted
        Returns:
        an iterable containing the result of the aggregation operation
        Since:
        1.0
      • aggregateWithQuery

        @GloopObjectParameter("mongoAggregateCursor[]:object")
        public static GloopCursor aggregateWithQuery​(@NotNull
                                                     @NotNull String connectionName,
                                                     @NotNull
                                                     @NotNull String databaseName,
                                                     @NotNull
                                                     @NotNull String collectionName,
                                                     @NotNull
                                                     @NotNull List<String> pipelineQueries,
                                                     ClientSession clientSession,
                                                     @GloopParameter(defaultValue="false")
                                                     boolean closeClient,
                                                     GloopExecutionContext context)
        Aggregates documents according to the specified aggregation pipeline.
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        collectionName - the collection name
        pipelineQueries - the aggregation pipeline queries
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        closeClient - boolean stating whether the cursor will close the mongoDb client after it has been exhausted
        Returns:
        an iterable containing the result of the aggregation operation
        Since:
        1.0
      • watch

        public static ChangeStreamIterable<org.bson.Document> watch​(@NotNull
                                                                    @NotNull String connectionName,
                                                                    ClientSession clientSession,
                                                                    List<? extends org.bson.conversions.Bson> pipeline)
        Creates a change stream for this client.
        Parameters:
        connectionName - the name of the mongo db connection
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        pipeline - the aggregation pipeline to apply to the change stream. Leave as null if there are no queries
        Returns:
        the change stream iterable
        Since:
        1.0
      • watch

        @GloopObjectParameter("output{\n  mongoAggregateCursor[]*{\n  }\n}")
        public static void watch​(@NotNull
                                 @NotNull String connectionName,
                                 @NotNull
                                 @NotNull String databaseName,
                                 ClientSession clientSession,
                                 List<? extends org.bson.conversions.Bson> pipeline,
                                 @NotNull
                                 @NotNull String gloopService)
        Creates a change stream for this database.
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        pipeline - the aggregation pipeline to apply to the change stream
        gloopService - The gloop service to invoke when a change is made
        Since:
        1.0
      • watchWithQuery

        public static ChangeStreamIterable<org.bson.Document> watchWithQuery​(@NotNull
                                                                             @NotNull String connectionName,
                                                                             ClientSession clientSession,
                                                                             List<String> pipelineQueries)
        Creates a change stream for this client.
        Parameters:
        connectionName - the name of the mongo db connection
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        pipelineQueries - the aggregation pipeline queries to apply to the change stream. Leave as null if there are no queries
        Returns:
        the change stream iterable
        Since:
        1.0
      • mapReduce

        @GloopObjectParameter("mongoDbMapReduceCursor[]:object")
        public static <T> GloopCursor mapReduce​(@NotNull
                                                @NotNull String connectionName,
                                                @NotNull
                                                @NotNull String databaseName,
                                                @NotNull
                                                @NotNull String collectionName,
                                                ClientSession clientSession,
                                                Class<T> resultClass,
                                                @NotNull
                                                @NotNull String mapFunction,
                                                @NotNull
                                                @NotNull String reduceFunction,
                                                @GloopParameter(defaultValue="false")
                                                boolean closeClient,
                                                GloopExecutionContext context)
        Aggregates documents according to the specified map-reduce function.
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        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
        closeClient - boolean stating whether the cursor will close the mongoDb client after it has been exhausted particular key.
        Returns:
        an iterable containing the result of the map-reduce operation
        Since:
        1.0
      • bulkWrite

        @GloopObjectParameter("mongoDbBulkWriteCursor[]:object:::::com.mongodb.client.model.WriteModel")
        public static GloopCursor bulkWrite​(@NotNull
                                            @NotNull String connectionName,
                                            @NotNull
                                            @NotNull String databaseName,
                                            @NotNull
                                            @NotNull String collectionName,
                                            ClientSession clientSession,
                                            @GloopParameter(defaultValue="10000")
                                            int batchSize,
                                            @GloopParameter(defaultValue="false")
                                            boolean closeClient,
                                            @GloopParameter(defaultValue="false")
                                            boolean ordered,
                                            Boolean bypassDocumentValidation,
                                            GloopExecutionContext context)
        Executes a mix of inserts, updates, replaces, and deletes.

        Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. The eligibility for retryable write support for bulk operations is determined on the whole bulk write. If the requests contain any UpdateManyModels or DeleteManyModels then the bulk operation will not support retryable writes.

        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        batchSize - how many write models to cache before sending them to mongo db
        closeClient - a boolean stating whether to close the client once the cursor has been closed
        Returns:
        a gloop output cursor that accepts mongo db write models
        Since:
        1.0
      • insertOne

        public static void insertOne​(@NotNull
                                     @NotNull String connectionName,
                                     @NotNull
                                     @NotNull String databaseName,
                                     @NotNull
                                     @NotNull String collectionName,
                                     ClientSession clientSession,
                                     @NotNull
                                     @NotNull GloopModel document,
                                     Boolean bypassDocumentValidation)
        Inserts the provided document. If the document is missing an identifier, the driver should generate one.

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

        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        document - the document to insert
        Throws:
        MongoWriteException - if the write failed due some other failure specific to the insert command
        MongoWriteConcernException - if the write failed due being unable to fulfil the write concern
        MongoCommandException - if the write failed due to document validation reasons
        MongoException - if the write failed due some other failure
        Since:
        1.0
      • deleteOne

        public static DeleteResult deleteOne​(@NotNull
                                             @NotNull String connectionName,
                                             @NotNull
                                             @NotNull String databaseName,
                                             @NotNull
                                             @NotNull String collectionName,
                                             ClientSession clientSession,
                                             org.bson.conversions.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.

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

        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        filter - the query filter to apply the the delete operation
        options - the options to apply to the delete operation
        Returns:
        the result of the remove one operation
        Throws:
        MongoWriteException - if the write failed due some other failure specific to the delete command
        MongoWriteConcernException - if the write failed due being unable to fulfil the write concern
        MongoException - if the write failed due some other failure
        Since:
        1.0
      • deleteOne

        public static DeleteResult deleteOne​(@NotNull
                                             @NotNull String connectionName,
                                             @NotNull
                                             @NotNull String databaseName,
                                             @NotNull
                                             @NotNull String collectionName,
                                             ClientSession clientSession,
                                             String filterQuery,
                                             DeleteOptions options)
        Removes at most one document from the collection that matches the given filter. If no documents match, the collection is not modified.

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

        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        filterQuery - the query filter to apply the the delete operation
        options - the options to apply to the delete operation
        Returns:
        the result of the remove one operation
        Throws:
        MongoWriteException - if the write failed due some other failure specific to the delete command
        MongoWriteConcernException - if the write failed due being unable to fulfil the write concern
        MongoException - if the write failed due some other failure
        Since:
        1.0
      • deleteMany

        public static DeleteResult deleteMany​(@NotNull
                                              @NotNull String connectionName,
                                              @NotNull
                                              @NotNull String databaseName,
                                              @NotNull
                                              @NotNull String collectionName,
                                              ClientSession clientSession,
                                              org.bson.conversions.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:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        filter - the query filter to apply the the delete operation
        options - the options to apply to the delete operation
        Returns:
        the result of the remove many operation
        Throws:
        MongoWriteException - if the write failed due some other failure specific to the delete command
        MongoWriteConcernException - if the write failed due being unable to fulfil the write concern
        MongoException - if the write failed due some other failure
        Since:
        1.0
      • deleteMany

        public static DeleteResult deleteMany​(@NotNull
                                              @NotNull String connectionName,
                                              @NotNull
                                              @NotNull String databaseName,
                                              @NotNull
                                              @NotNull String collectionName,
                                              ClientSession clientSession,
                                              String filterQuery,
                                              DeleteOptions options)
        Removes all documents from the collection that match the given query filter. If no documents match, the collection is not modified.
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        filterQuery - the query filter to apply the the delete operation
        options - the options to apply to the delete operation
        Returns:
        the result of the remove many operation
        Throws:
        MongoWriteException - if the write failed due some other failure specific to the delete command
        MongoWriteConcernException - if the write failed due being unable to fulfil the write concern
        MongoException - if the write failed due some other failure
        Since:
        1.0
      • replaceOne

        public static UpdateResult replaceOne​(@NotNull
                                              @NotNull String connectionName,
                                              @NotNull
                                              @NotNull String databaseName,
                                              @NotNull
                                              @NotNull String collectionName,
                                              ClientSession clientSession,
                                              org.bson.conversions.Bson filter,
                                              GloopModel replacement,
                                              ReplaceOptions options)
        Replace a 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:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        filter - the query filter to apply the the replace operation
        replacement - the replacement document
        options - the options to apply to the replace operation
        Returns:
        the result of the replace one operation
        Throws:
        MongoWriteException - if the write failed due some other failure specific to the replace command
        MongoWriteConcernException - if the write failed due being unable to fulfil the write concern
        MongoException - if the write failed due some other failure
        Since:
        1.0
      • replaceOne

        public static UpdateResult replaceOne​(@NotNull
                                              @NotNull String connectionName,
                                              @NotNull
                                              @NotNull String databaseName,
                                              @NotNull
                                              @NotNull String collectionName,
                                              ClientSession clientSession,
                                              String filterQuery,
                                              GloopModel replacement,
                                              ReplaceOptions options)
        Replace a 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:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        filterQuery - the query filter to apply the the replace operation
        replacement - the replacement document
        options - the options to apply to the replace operation
        Returns:
        the result of the replace one operation
        Throws:
        MongoWriteException - if the write failed due some other failure specific to the replace command
        MongoWriteConcernException - if the write failed due being unable to fulfil the write concern
        MongoException - if the write failed due some other failure
        Since:
        1.0
      • updateOne

        public static UpdateResult updateOne​(@NotNull
                                             @NotNull String connectionName,
                                             @NotNull
                                             @NotNull String databaseName,
                                             @NotNull
                                             @NotNull String collectionName,
                                             ClientSession clientSession,
                                             @NotNull
                                             @NotNull org.bson.conversions.Bson filter,
                                             @NotNull
                                             @NotNull org.bson.conversions.Bson update,
                                             UpdateOptions updateOptions)
        Update a single document in the collection according to the specified arguments.

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

        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        updateOptions - the updateOptions to apply to the update operation
        Returns:
        the result of the update one operation
        Throws:
        MongoWriteException - if the write failed due some other failure specific to the update command
        MongoWriteConcernException - if the write failed due being unable to fulfil the write concern
        MongoException - if the write failed due some other failure
        Since:
        1.0
      • updateOne

        public static UpdateResult updateOne​(@NotNull
                                             @NotNull String connectionName,
                                             @NotNull
                                             @NotNull String databaseName,
                                             @NotNull
                                             @NotNull String collectionName,
                                             ClientSession clientSession,
                                             @NotNull
                                             @NotNull String filter,
                                             @NotNull
                                             @NotNull String update,
                                             UpdateOptions updateOptions)
        Update a single document in the collection according to the specified arguments.

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

        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        updateOptions - the updateOptions to apply to the update operation
        Returns:
        the result of the update one operation
        Throws:
        MongoWriteException - if the write failed due some other failure specific to the update command
        MongoWriteConcernException - if the write failed due being unable to fulfil the write concern
        MongoException - if the write failed due some other failure
        Since:
        1.0
      • updateMany

        public static UpdateResult updateMany​(@NotNull
                                              @NotNull String connectionName,
                                              @NotNull
                                              @NotNull String databaseName,
                                              @NotNull
                                              @NotNull String collectionName,
                                              ClientSession clientSession,
                                              org.bson.conversions.Bson filter,
                                              org.bson.conversions.Bson update,
                                              UpdateOptions updateOptions)
        Update all documents in the collection according to the specified arguments.
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        updateOptions - the options to apply to the update operation
        Returns:
        the result of the update many operation
        Throws:
        MongoWriteException - if the write failed due some other failure specific to the update command
        MongoWriteConcernException - if the write failed due being unable to fulfil the write concern
        MongoException - if the write failed due some other failure
        Since:
        1.0
      • updateMany

        public static UpdateResult updateMany​(@NotNull
                                              @NotNull String connectionName,
                                              @NotNull
                                              @NotNull String databaseName,
                                              @NotNull
                                              @NotNull String collectionName,
                                              ClientSession clientSession,
                                              String filter,
                                              String update,
                                              UpdateOptions updateOptions)
        Update all documents in the collection according to the specified arguments.
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        updateOptions - the options to apply to the update operation
        Returns:
        the result of the update many operation
        Throws:
        MongoWriteException - if the write failed due some other failure specific to the update command
        MongoWriteConcernException - if the write failed due being unable to fulfil the write concern
        MongoException - if the write failed due some other failure
        Since:
        1.0
      • findOneAndDelete

        @Nullable
        public static GloopModel findOneAndDelete​(@NotNull
                                                  @NotNull String connectionName,
                                                  @NotNull
                                                  @NotNull String databaseName,
                                                  @NotNull
                                                  @NotNull String collectionName,
                                                  ClientSession clientSession,
                                                  @NotNull
                                                  @NotNull org.bson.conversions.Bson filter,
                                                  FindOneAndDeleteOptions options)
        Atomically find a document and remove it.

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

        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        filter - the query filter to find the document with
        options - the options to apply to the operation
        Returns:
        the document that was removed. If no documents matched the query filter, then null will be returned
        Since:
        1.0
      • findOneAndDelete

        @Nullable
        public static GloopModel findOneAndDelete​(@NotNull
                                                  @NotNull String connectionName,
                                                  @NotNull
                                                  @NotNull String databaseName,
                                                  @NotNull
                                                  @NotNull String collectionName,
                                                  ClientSession clientSession,
                                                  @NotNull
                                                  @NotNull String filter,
                                                  FindOneAndDeleteOptions options)
        Atomically find a document and remove it.

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

        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        filter - the query filter to find the document with
        options - the options to apply to the operation
        Returns:
        the document that was removed. If no documents matched the query filter, then null will be returned
        Since:
        1.0
      • findOneAndReplace

        @Nullable
        public static GloopModel findOneAndReplace​(@NotNull
                                                   @NotNull String connectionName,
                                                   @NotNull
                                                   @NotNull String databaseName,
                                                   @NotNull
                                                   @NotNull String collectionName,
                                                   ClientSession clientSession,
                                                   org.bson.conversions.Bson filter,
                                                   GloopModel replacement,
                                                   FindOneAndReplaceOptions options)
        Atomically find a document and replace it.

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

        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        filter - the query filter to apply the the replace operation
        replacement - the replacement document
        options - the options to apply to the operation
        Returns:
        the document that was replaced. Depending on the value of the 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.0
      • findOneAndReplace

        @Nullable
        public static GloopModel findOneAndReplace​(@NotNull
                                                   @NotNull String connectionName,
                                                   @NotNull
                                                   @NotNull String databaseName,
                                                   @NotNull
                                                   @NotNull String collectionName,
                                                   ClientSession clientSession,
                                                   String filter,
                                                   GloopModel replacement,
                                                   FindOneAndReplaceOptions options)
        Atomically find a document and replace it.

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

        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        filter - the query filter to apply the the replace operation
        replacement - the replacement document
        options - the options to apply to the operation
        Returns:
        the document that was replaced. Depending on the value of the 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.0
      • findOneAndUpdate

        @Nullable
        public static GloopModel findOneAndUpdate​(@NotNull
                                                  @NotNull String connectionName,
                                                  @NotNull
                                                  @NotNull String databaseName,
                                                  @NotNull
                                                  @NotNull String collectionName,
                                                  ClientSession clientSession,
                                                  @NotNull
                                                  @NotNull org.bson.conversions.Bson filter,
                                                  @NotNull
                                                  @NotNull org.bson.conversions.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:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        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:
        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.0
      • findOneAndUpdate

        @Nullable
        public static GloopModel findOneAndUpdate​(@NotNull
                                                  @NotNull String connectionName,
                                                  @NotNull
                                                  @NotNull String databaseName,
                                                  @NotNull
                                                  @NotNull String collectionName,
                                                  ClientSession clientSession,
                                                  @NotNull
                                                  @NotNull String filter,
                                                  @NotNull
                                                  @NotNull String 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:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        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:
        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.0
      • createIndex

        public static String createIndex​(@NotNull
                                         @NotNull String connectionName,
                                         @NotNull
                                         @NotNull String databaseName,
                                         @NotNull
                                         @NotNull String collectionName,
                                         ClientSession clientSession,
                                         @NotNull
                                         @NotNull org.bson.conversions.Bson keys,
                                         IndexOptions indexOptions)
        Create an index with the given keys and options.
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        keys - an object describing the index key(s), which may not be null.
        indexOptions - the options for the index
        Returns:
        the index name
        Since:
        1.0
      • createIndex

        public static String createIndex​(@NotNull
                                         @NotNull String connectionName,
                                         @NotNull
                                         @NotNull String databaseName,
                                         @NotNull
                                         @NotNull String collectionName,
                                         ClientSession clientSession,
                                         @NotNull
                                         @NotNull String keys,
                                         IndexOptions indexOptions)
        Create an index with the given keys and options.
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        keys - an object describing the index key(s), which may not be null.
        indexOptions - the options for the index
        Returns:
        the index name
        Since:
        1.0
      • createIndexes

        public static List<String> createIndexes​(@NotNull
                                                 @NotNull String connectionName,
                                                 @NotNull
                                                 @NotNull String databaseName,
                                                 @NotNull
                                                 @NotNull String collectionName,
                                                 ClientSession clientSession,
                                                 List<IndexModel> indexes,
                                                 CreateIndexOptions createIndexOptions)
        Create multiple indexes.
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        indexes - the list of indexes
        createIndexOptions - options to use when creating indexes
        Returns:
        the list of index names
        Since:
        1.0
      • listIndexes

        public static GloopCursor listIndexes​(@NotNull
                                              @NotNull String connectionName,
                                              @NotNull
                                              @NotNull String databaseName,
                                              @NotNull
                                              @NotNull String collectionName,
                                              ClientSession clientSession,
                                              @GloopParameter(defaultValue="false")
                                              boolean closeClient,
                                              GloopExecutionContext context)
        Get all the indexes in this collection.
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        Returns:
        the list indexes iterable interface
        Since:
        1.0
      • dropIndex

        public static void dropIndex​(@NotNull
                                     @NotNull String connectionName,
                                     @NotNull
                                     @NotNull String databaseName,
                                     @NotNull
                                     @NotNull String collectionName,
                                     ClientSession clientSession,
                                     @NotNull
                                     @NotNull String indexName,
                                     DropIndexOptions dropIndexOptions)
        Drops the index given its name.
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        indexName - the name of the index to remove
        dropIndexOptions - the options to use when dropping indexes
        Since:
        1.0
      • dropIndexes

        public static void dropIndexes​(@NotNull
                                       @NotNull String connectionName,
                                       @NotNull
                                       @NotNull String databaseName,
                                       @NotNull
                                       @NotNull String collectionName,
                                       ClientSession clientSession,
                                       DropIndexOptions dropIndexOptions)
        Drop all the indexes on this collection, except for the default on _id.
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        dropIndexOptions - the options to use when dropping indexes
        Since:
        1.0
      • renameCollection

        public static void renameCollection​(@NotNull
                                            @NotNull String connectionName,
                                            @NotNull
                                            @NotNull String databaseName,
                                            @NotNull
                                            @NotNull String collectionName,
                                            ClientSession clientSession,
                                            MongoNamespace newCollectionNamespace,
                                            @GloopParameter(defaultValue="false")
                                            boolean dropTarget)
        Rename the collection with oldCollectionName to the newCollectionName.
        Parameters:
        connectionName - the name of the mongo db connection
        databaseName - the database name
        clientSession - the client session with which to associate this operation. Leave as null if there is no session
        newCollectionNamespace - the name the collection will be renamed to
        dropTarget - if mongodb should drop the target of renameCollection prior to renaming the collection.
        Throws:
        MongoServerException - if you provide a newCollectionName that is the name of an existing collection and dropTarget is false, or if the oldCollectionName is the name of a collection that doesn't exist
        Since:
        1.0