Class RemoteMongoCollectionImpl<DocumentT>

    • Method Detail

      • withDocumentClass

        public <NewDocumentT> RemoteMongoCollection<NewDocumentT> withDocumentClass​(Class<NewDocumentT> clazz)
        Description copied from interface: RemoteMongoCollection
        Create a new RemoteMongoCollection instance with a different default class to cast any documents returned from the database into.
        Specified by:
        withDocumentClass in interface RemoteMongoCollection<DocumentT>
        Type Parameters:
        NewDocumentT - The type that the new collection will encode documents from and decode documents to.
        Parameters:
        clazz - the default class to cast any documents returned from the database into.
        Returns:
        a new RemoteMongoCollection instance with the different default class
      • count

        public Task<Long> count()
        Counts the number of documents in the collection.
        Specified by:
        count in interface RemoteMongoCollection<DocumentT>
        Returns:
        a task containing the number of documents in the collection
      • count

        public Task<Long> count​(Bson filter)
        Counts the number of documents in the collection according to the given options.
        Specified by:
        count in interface RemoteMongoCollection<DocumentT>
        Parameters:
        filter - the query filter
        Returns:
        a task containing the number of documents in the collection
      • count

        public Task<Long> count​(Bson filter,
                                RemoteCountOptions options)
        Counts the number of documents in the collection according to the given options.
        Specified by:
        count in interface RemoteMongoCollection<DocumentT>
        Parameters:
        filter - the query filter
        options - the options describing the count
        Returns:
        a task containing the number of documents in the collection
      • findOne

        public <ResultT> Task<ResultT> findOne​(Class<ResultT> resultClass)
        Finds a document in the collection.
        Specified by:
        findOne in interface RemoteMongoCollection<DocumentT>
        Type Parameters:
        ResultT - the target document type
        Parameters:
        resultClass - the class to decode each document into
        Returns:
        a task containing the result of the find one operation
      • findOne

        public <ResultT> Task<ResultT> findOne​(Bson filter,
                                               Class<ResultT> resultClass)
        Finds a document in the collection.
        Specified by:
        findOne in interface RemoteMongoCollection<DocumentT>
        Type Parameters:
        ResultT - the target document type of the iterable.
        Parameters:
        filter - the query filter
        resultClass - the class to decode each document into
        Returns:
        a task containing the result of the find one operation
      • findOne

        public <ResultT> Task<ResultT> findOne​(Bson filter,
                                               RemoteFindOptions options,
                                               Class<ResultT> resultClass)
        Finds a document in the collection.
        Specified by:
        findOne in interface RemoteMongoCollection<DocumentT>
        Type Parameters:
        ResultT - the target document type of the iterable.
        Parameters:
        filter - the query filter
        options - A RemoteFindOptions struct
        resultClass - the class to decode each document into
        Returns:
        a task containing the result of the find one operation
      • find

        public <ResultT> RemoteFindIterable<ResultT> find​(Class<ResultT> resultClass)
        Finds all documents in the collection.
        Specified by:
        find in interface RemoteMongoCollection<DocumentT>
        Type Parameters:
        ResultT - the target document type of the iterable.
        Parameters:
        resultClass - the class to decode each document into
        Returns:
        the find iterable interface
      • find

        public <ResultT> RemoteFindIterable<ResultT> find​(Bson filter,
                                                          Class<ResultT> resultClass)
        Finds all documents in the collection.
        Specified by:
        find in interface RemoteMongoCollection<DocumentT>
        Type Parameters:
        ResultT - the target document type of the iterable.
        Parameters:
        filter - the query filter
        resultClass - the class to decode each document into
        Returns:
        the find iterable interface
      • aggregate

        public <ResultT> RemoteAggregateIterable<ResultT> aggregate​(List<? extends Bson> pipeline,
                                                                    Class<ResultT> resultClass)
        Aggregates documents according to the specified aggregation pipeline.
        Specified by:
        aggregate in interface RemoteMongoCollection<DocumentT>
        Type Parameters:
        ResultT - 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
      • insertOne

        public Task<RemoteInsertOneResult> insertOne​(DocumentT document)
        Inserts the provided document. If the document is missing an identifier, the client should generate one.
        Specified by:
        insertOne in interface RemoteMongoCollection<DocumentT>
        Parameters:
        document - the document to insert
        Returns:
        a task containing the result of the insert one operation
      • deleteOne

        public Task<RemoteDeleteResult> deleteOne​(Bson filter)
        Removes at most one document from the collection that matches the given filter. If no documents match, the collection is not modified.
        Specified by:
        deleteOne in interface RemoteMongoCollection<DocumentT>
        Parameters:
        filter - the query filter to apply the the delete operation
        Returns:
        a task containing the result of the remove one operation
      • deleteMany

        public Task<RemoteDeleteResult> deleteMany​(Bson filter)
        Removes all documents from the collection that match the given query filter. If no documents match, the collection is not modified.
        Specified by:
        deleteMany in interface RemoteMongoCollection<DocumentT>
        Parameters:
        filter - the query filter to apply the the delete operation
        Returns:
        a task containing the result of the remove many operation
      • updateOne

        public Task<RemoteUpdateResult> updateOne​(Bson filter,
                                                  Bson update)
        Update a single document in the collection according to the specified arguments.
        Specified by:
        updateOne in interface RemoteMongoCollection<DocumentT>
        Parameters:
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        Returns:
        a task containing the result of the update one operation
      • updateOne

        public Task<RemoteUpdateResult> updateOne​(Bson filter,
                                                  Bson update,
                                                  RemoteUpdateOptions updateOptions)
        Update a single document in the collection according to the specified arguments.
        Specified by:
        updateOne in interface RemoteMongoCollection<DocumentT>
        Parameters:
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        updateOptions - the options to apply to the update operation
        Returns:
        a task containing the result of the update one operation
      • updateMany

        public Task<RemoteUpdateResult> updateMany​(Bson filter,
                                                   Bson update)
        Update all documents in the collection according to the specified arguments.
        Specified by:
        updateMany in interface RemoteMongoCollection<DocumentT>
        Parameters:
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        Returns:
        a task containing the result of the update many operation
      • updateMany

        public Task<RemoteUpdateResult> updateMany​(Bson filter,
                                                   Bson update,
                                                   RemoteUpdateOptions updateOptions)
        Update all documents in the collection according to the specified arguments.
        Specified by:
        updateMany in interface RemoteMongoCollection<DocumentT>
        Parameters:
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        updateOptions - the options to apply to the update operation
        Returns:
        a task containing the result of the update many operation
      • findOneAndUpdate

        public Task<DocumentT> findOneAndUpdate​(Bson filter,
                                                Bson update)
        Finds a document in the collection and performs the given update.
        Specified by:
        findOneAndUpdate in interface RemoteMongoCollection<DocumentT>
        Parameters:
        filter - the query filter
        update - the update document
        Returns:
        a task containing the resulting document
      • findOneAndUpdate

        public <ResultT> Task<ResultT> findOneAndUpdate​(Bson filter,
                                                        Bson update,
                                                        Class<ResultT> resultClass)
        Finds a document in the collection and performs the given update.
        Specified by:
        findOneAndUpdate in interface RemoteMongoCollection<DocumentT>
        Type Parameters:
        ResultT - the target document type of the iterable.
        Parameters:
        filter - the query filter
        update - the update document
        resultClass - the class to decode each document into
        Returns:
        a task containing the resulting document
      • findOneAndUpdate

        public <ResultT> Task<ResultT> findOneAndUpdate​(Bson filter,
                                                        Bson update,
                                                        RemoteFindOneAndModifyOptions options,
                                                        Class<ResultT> resultClass)
        Finds a document in the collection and performs the given update.
        Specified by:
        findOneAndUpdate in interface RemoteMongoCollection<DocumentT>
        Type Parameters:
        ResultT - the target document type of the iterable.
        Parameters:
        filter - the query filter
        update - the update document
        options - A RemoteFindOneAndModifyOptions struct
        resultClass - the class to decode each document into
        Returns:
        a task containing the resulting document
      • findOneAndReplace

        public Task<DocumentT> findOneAndReplace​(Bson filter,
                                                 Bson replacement)
        Finds a document in the collection and replaces it with the given document
        Specified by:
        findOneAndReplace in interface RemoteMongoCollection<DocumentT>
        Parameters:
        filter - the query filter
        replacement - the document to replace the matched document with
        Returns:
        a task containing the resulting document
      • findOneAndReplace

        public <ResultT> Task<ResultT> findOneAndReplace​(Bson filter,
                                                         Bson replacement,
                                                         Class<ResultT> resultClass)
        Finds a document in the collection and replaces it with the given document
        Specified by:
        findOneAndReplace in interface RemoteMongoCollection<DocumentT>
        Type Parameters:
        ResultT - the target document type of the iterable.
        Parameters:
        filter - the query filter
        replacement - the document to replace the matched document with
        resultClass - the class to decode each document into
        Returns:
        a task containing the resulting document
      • findOneAndReplace

        public Task<DocumentT> findOneAndReplace​(Bson filter,
                                                 Bson replacement,
                                                 RemoteFindOneAndModifyOptions options)
        Finds a document in the collection and replaces it with the given document
        Specified by:
        findOneAndReplace in interface RemoteMongoCollection<DocumentT>
        Parameters:
        filter - the query filter
        replacement - the document to replace the matched document with
        options - A RemoteFindOneAndModifyOptions struct
        Returns:
        a task containing the resulting document
      • findOneAndReplace

        public <ResultT> Task<ResultT> findOneAndReplace​(Bson filter,
                                                         Bson replacement,
                                                         RemoteFindOneAndModifyOptions options,
                                                         Class<ResultT> resultClass)
        Finds a document in the collection and replaces it with the given document
        Specified by:
        findOneAndReplace in interface RemoteMongoCollection<DocumentT>
        Type Parameters:
        ResultT - the target document type of the iterable.
        Parameters:
        filter - the query filter
        replacement - the document to replace the matched document with
        options - A RemoteFindOneAndModifyOptions struct
        resultClass - the class to decode each document into
        Returns:
        a task containing the resulting document
      • findOneAndDelete

        public <ResultT> Task<ResultT> findOneAndDelete​(Bson filter,
                                                        Class<ResultT> resultClass)
        Finds a document in the collection and delete it.
        Specified by:
        findOneAndDelete in interface RemoteMongoCollection<DocumentT>
        Type Parameters:
        ResultT - the target document type of the iterable.
        Parameters:
        filter - the query filter
        resultClass - the class to decode each document into
        Returns:
        a task containing the resulting document
      • findOneAndDelete

        public <ResultT> Task<ResultT> findOneAndDelete​(Bson filter,
                                                        RemoteFindOneAndModifyOptions options,
                                                        Class<ResultT> resultClass)
        Finds a document in the collection and delete it.
        Specified by:
        findOneAndDelete in interface RemoteMongoCollection<DocumentT>
        Type Parameters:
        ResultT - the target document type of the iterable.
        Parameters:
        filter - the query filter
        options - A RemoteFindOneAndModifyOptions struct
        resultClass - the class to decode each document into
        Returns:
        a task containing the resulting document
      • watchWithFilter

        public Task<AsyncChangeStream<DocumentT,​ChangeEvent<DocumentT>>> watchWithFilter​(Document matchFilter)
        Description copied from interface: RemoteMongoCollection
        Watches a collection. The provided BSON document will be used as a match expression filter on the change events coming from the stream. See https://docs.mongodb.com/manual/reference/operator/aggregation/match/ for documentation around how to define a match filter. Defining the match expression to filter ChangeEvents is similar to defining the match expression for triggers: https://docs.mongodb.com/stitch/triggers/database-triggers/
        Specified by:
        watchWithFilter in interface RemoteMongoCollection<DocumentT>
        Parameters:
        matchFilter - the $match filter to apply to incoming change events
        Returns:
        the stream of change events.
      • watchWithFilter

        public Task<AsyncChangeStream<DocumentT,​ChangeEvent<DocumentT>>> watchWithFilter​(BsonDocument matchFilter)
        Description copied from interface: RemoteMongoCollection
        Watches a collection. The provided BSON document will be used as a match expression filter on the change events coming from the stream. See https://docs.mongodb.com/manual/reference/operator/aggregation/match/ for documentation around how to define a match filter. Defining the match expression to filter ChangeEvents is similar to defining the match expression for triggers: https://docs.mongodb.com/stitch/triggers/database-triggers/
        Specified by:
        watchWithFilter in interface RemoteMongoCollection<DocumentT>
        Parameters:
        matchFilter - the $match filter to apply to incoming change events
        Returns:
        the stream of change events.
      • sync

        public Sync<DocumentT> sync()
        Description copied from interface: RemoteMongoCollection
        A set of synchronization related operations on this collection.

        WARNING: This is a BETA feature and the API and on-device storage format are subject to change.

        Specified by:
        sync in interface RemoteMongoCollection<DocumentT>
        Returns:
        set of sync operations for this collection