DITWriteTransactionPendingCursorOperation

@interface DITWriteTransactionPendingCursorOperation : NSObject

These objects are returned when using find and findAll functionality on DITScopedWriteTransactions.

You can use them to perform updates on documents and remove or evict documents.

  • Limit the number of documents that get returned when querying a collection for matching documents.

    Declaration

    Objective-C

    - (nonnull DITWriteTransactionPendingCursorOperation *)limit:(int)limit;

    Parameters

    limit

    The maximum number of documents that will be returned.

    Return Value

    A DITWriteTransactionPendingCursorOperation that you can chain further function calls and then either get the matching documents immediately or get updates about them over time.

  • Offset the resulting set of matching documents.

    This is useful if you aren’t interested in the first N matching documents for one reason or another. For example, you might already have queried the collection and obtained the first 20 matching documents and so you might want to run the same query as you did previously but ignore the first 20 matching documents, and that is when you would use offset.

    Declaration

    Objective-C

    - (nonnull DITWriteTransactionPendingCursorOperation *)offset:(uint)offset;

    Parameters

    offset

    The number of matching documents that you want the eventual resulting set of matching documents to be offset by (and thus not include).

    Return Value

    A DITWriteTransactionPendingCursorOperation that you can chain further function calls and then either get the matching documents immediately or get updates about them over time.

  • Sort the documents that match the query provided in the preceding find-like function call.

    Declaration

    Objective-C

    - (nonnull DITWriteTransactionPendingCursorOperation *)
             sort:(nonnull NSString *)query
        direction:(DITSortDirection)direction;

    Parameters

    query

    The query specifies the logic to be used when sorting the matching documents.

    direction

    Specify whether you want the sorting order to be ascending or descending.

    Return Value

    A DITWriteTransactionPendingCursorOperation that you can chain further function calls and then either get the matching documents immediately or get updates about them over time.

  • Execute the query generated by the preceding function chaining and return the list of matching documents.

    Declaration

    Objective-C

    - (nonnull NSArray<DITDocument *> *)exec;

    Return Value

    A list of DITDocuments matching the query generated by the preceding function chaining.

  • Remove all documents that match the query generated by the preceding function chaining.

    Declaration

    Objective-C

    - (nonnull NSArray<DITDocumentID *> *)remove;

    Return Value

    A list containing the IDs of the documents that were removed.

  • Evict all documents that match the query generated by the preceding function chaining.

    Declaration

    Objective-C

    - (nonnull NSArray<DITDocumentID *> *)evict;

    Return Value

    A list containing the IDs of the documents that were evicted.

  • Update documents that match the query generated by the preceding function chaining.

    Declaration

    Objective-C

    - (nonnull NSDictionary<DITDocumentID *, NSArray<DITUpdateResult *> *> *)
        updateWithBlock:
            (nonnull void (^)(NSArray<DITMutableDocument *> *_Nonnull))block;

    Parameters

    block

    A block that gets called with all of the documents matching the query. The documents are DITMutableDocuments so you can call update-related functions on them.

    Return Value

    A dictionary mapping document IDs to lists of DITUpdateResults that describes the updates that were performed for each document.