DITScopedWriteTransaction

@interface DITScopedWriteTransaction : NSObject

Exposes functionality that allows you to perform multiple operations on the store within a single write transaction.

A DITScopedWriteTransaction is scoped to a specific collection, obtained by calling scoped on a DITWriteTransaction.

  • The name of the collection that the scoped write transaction is scoped to.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSString *_Nonnull collectionName;
  • Inserts a new document into the collection and returns its ID.

    Declaration

    Objective-C

    - (nullable NSString *)insert:(nonnull NSDictionary<NSString *, id> *)content
                            error:(NSError *_Nullable *_Nullable)error;

    Parameters

    content

    The new document to insert.

    error

    On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

    Return Value

    The ID of the inserted document, or nil if insertion failed.

  • Inserts a new document into the collection and returns its ID.

    Declaration

    Objective-C

    - (nullable NSString *)insert:(nonnull NSDictionary<NSString *, id> *)content
                           withID:(nullable NSString *)id
                            error:(NSError *_Nullable *_Nullable)error;

    Parameters

    content

    The new document to insert.

    id

    The ID to use for the document. If NULL then Ditto will automatically assign an ID.

    error

    On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

    Return Value

    The ID of the inserted document, or nil if insertion failed.

  • Inserts a new document into the collection and returns its ID.

    Declaration

    Objective-C

    - (nullable NSString *)insert:(nonnull NSDictionary<NSString *, id> *)content
                        isDefault:(BOOL)isDefault
                            error:(NSError *_Nullable *_Nullable)error;

    Parameters

    content

    The new document to insert.

    isDefault

    Whether or not the data being inserted should be treated as default data or not. Set this to true if you want to set a default value that you expect to be overwritten by other devices in the network. The default value is false.

    error

    On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

    Return Value

    The ID of the inserted document, or nil if insertion failed.

  • Insert a document into the scoped collection.

    Declaration

    Objective-C

    - (nullable NSString *)insert:(nonnull NSDictionary<NSString *, id> *)content
                           withID:(nullable NSString *)id
                        isDefault:(BOOL)isDefault
                            error:(NSError *_Nullable *_Nullable)error;

    Parameters

    content

    The document to insert.

    id

    The ID to use for the document. If NULL then Ditto will automatically assign an ID.

    isDefault

    Represents whether or not the data being inserted should be treated as default data or not. Set this to true if you want to set a default value that you expect to be overwritten by other devices in the network. The default value is false.

    Return Value

    The ID of the inserted document.

  • Generates a DITWriteTransactionPendingIDSpecificOperation with the provided document ID that can be used to update, remove, or evict the document.

    Declaration

    Objective-C

    - (nonnull DITWriteTransactionPendingIDSpecificOperation *)findByID:
        (nonnull NSString *)docID;

    Parameters

    docID

    The ID of the document.

    Return Value

    A DITWriteTransactionPendingIDSpecificOperation that you can chain function calls to to update, remove, or evict the document.

  • Generates a DITWriteTransactionPendingCursorOperation with the provided query that can be used to update, remove, or evict documents.

    Declaration

    Objective-C

    - (nonnull DITWriteTransactionPendingCursorOperation *)find:
        (nonnull NSString *)query;

    Parameters

    query

    The query to run against the collection.

    Return Value

    A DITWriteTransactionPendingCursorOperation that you can use to chain further query-related function calls to update, remove, or evict the documents.

  • Generates a DITWriteTransactionPendingCursorOperation that can be used to update, remove or evict documents.

    Declaration

    Objective-C

    - (nonnull DITWriteTransactionPendingCursorOperation *)findAll;

    Return Value

    A DITWriteTransactionPendingCursorOperation that you can use to chain further query-related function calls to update, remove, or evict the documents.