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; -
Convenience method, same as
upsert:writeStrategy:error:whereDITWriteStrategyMergeis passed forwriteStrategy.Declaration
Objective-C
- (nullable DITDocumentID *)upsert: (nonnull NSDictionary<NSString *, id> *)content error:(NSError *_Nullable *_Nullable)error; -
Inserts a new document into the collection and returns its ID. If the document already exists, the behavior is determined by the given
writeStrategy.Declaration
Objective-C
- (nullable DITDocumentID *)upsert: (nonnull NSDictionary<NSString *, id> *)content writeStrategy:(DITWriteStrategy)writeStrategy error:(NSError *_Nullable *_Nullable)error;Parameters
contentThe new document to insert.
writeStrategySpecifies the desired strategy for inserting a document.
errorOn 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 upserted document, or
nilif upsertion failed. -
Deprecated
use
upsert(:withID:writeStrategy:error:)instead.Inserts a new document into the collection and returns its ID.
@deprecated use
upsert:writeStrategy:error:instead.Declaration
Objective-C
- (nullable DITDocumentID *)insert: (nonnull NSDictionary<NSString *, id> *)content error:(NSError *_Nullable *_Nullable)error;Parameters
contentThe new document to insert.
errorOn 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
nilif insertion failed. -
Deprecated
use
upsert(:withID:writeStrategy:error:)instead.Inserts a new document into the collection and returns its ID.
@deprecated use
upsert:writeStrategy:error:instead.Declaration
Objective-C
- (nullable DITDocumentID *)insert: (nonnull NSDictionary<NSString *, id> *)content withID:(nullable DITDocumentID *)id error:(NSError *_Nullable *_Nullable)error;Parameters
contentThe new document to insert.
idThe ID to use for the document. If
NULLthen Ditto will automatically assign an ID.errorOn 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
nilif insertion failed. -
Deprecated
use
upsert(:withID:writeStrategy:error:)instead.Inserts a new document into the collection and returns its ID.
@deprecated use
upsert:writeStrategy:error:instead.Declaration
Objective-C
- (nullable DITDocumentID *)insert: (nonnull NSDictionary<NSString *, id> *)content isDefault:(BOOL)isDefault error:(NSError *_Nullable *_Nullable)error;Parameters
contentThe new document to insert.
isDefaultWhether or not the data being inserted should be treated as default data or not. Set this to
trueif you want to set a default value that you expect to be overwritten by other devices in the network. The default value isfalse.errorOn 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
nilif insertion failed. -
Deprecated
use
upsert(:withID:writeStrategy:error:)instead.Insert a document into the scoped collection.
@deprecated use
upsert:writeStrategy:error:instead.Declaration
Objective-C
- (nullable DITDocumentID *)insert: (nonnull NSDictionary<NSString *, id> *)content withID:(nullable DITDocumentID *)id isDefault:(BOOL)isDefault error:(NSError *_Nullable *_Nullable)error;Parameters
contentThe document to insert.
idThe ID to use for the document. If
NULLthen Ditto will automatically assign an ID.isDefaultRepresents whether or not the data being inserted should be treated as default data or not. Set this to
trueif you want to set a default value that you expect to be overwritten by other devices in the network. The default value isfalse.errorOn 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.
-
Deprecated
use
upsert(:withID:writeStrategy:error:)instead.Inserts a new document into the collection and returns its ID.
@deprecated use
upsert:writeStrategy:error:instead.Declaration
Objective-C
- (nullable DITDocumentID *)insert: (nonnull NSDictionary<NSString *, id> *)content writeStrategy:(DITWriteStrategy)writeStrategy error:(NSError *_Nullable *_Nullable)error;Parameters
contentThe new document to insert.
writeStrategySpecifies the desired strategy for inserting a document. The default value is
DITWriteStrategyOverwrite.errorOn 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
nilif insertion failed. -
Deprecated
use
upsert(:withID:writeStrategy:error:)instead.Inserts a new document into the collection and returns its ID.
@deprecated use
upsert:writeStrategy:error:instead.Declaration
Objective-C
- (nullable DITDocumentID *)insert: (nonnull NSDictionary<NSString *, id> *)content withID:(nullable DITDocumentID *)id writeStrategy:(DITWriteStrategy)writeStrategy error:(NSError *_Nullable *_Nullable)error;Parameters
contentThe new document to insert.
idThe ID to use for the document. If
NULLthen Ditto will automatically assign an ID.writeStrategySpecifies the desired strategy for inserting a document. The default value is
DITWriteStrategyOverwrite.errorOn 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
nilif insertion failed. -
Generates a
DITWriteTransactionPendingIDSpecificOperationwith the provided document ID that can be used to update, remove, or evict the document.Declaration
Objective-C
- (nonnull DITWriteTransactionPendingIDSpecificOperation *)findByID: (nonnull DITDocumentID *)docID;Parameters
docIDThe ID of the document.
Return Value
A
DITWriteTransactionPendingIDSpecificOperationthat you can chain function calls to to update, remove, or evict the document. -
Generates a
DITWriteTransactionPendingCursorOperationwith the provided query that can be used to update, remove, or evict documents.Declaration
Objective-C
- (nonnull DITWriteTransactionPendingCursorOperation *)find: (nonnull NSString *)query;Parameters
queryThe query to run against the collection.
Return Value
A
DITWriteTransactionPendingCursorOperationthat you can use to chain further query-related function calls to update, remove, or evict the documents. -
Generates a
DITWriteTransactionPendingCursorOperationwith the provided query that can be used to update, remove, or evict documents.This is the recommended method to use when performing queries on a collection if you have any dynamic data included in the query string. It allows you to provide a query string with placeholders, in the form of
$args.my_arg_name, along with an accompanying dictionary of arguments, in the form of{ "my_arg_name": "some value" }, and the placeholders will be appropriately replaced by the matching provided arguments from the dictionary. This includes handling things like wrapping strings in quotation marks and arrays in square brackets, for example.Declaration
Objective-C
- (nonnull DITWriteTransactionPendingCursorOperation *) find:(nonnull NSString *)query withArgs:(nonnull NSDictionary<NSString *, id> *)queryArgs;Parameters
queryThe query to run against the collection.
queryArgsThe arguments to use to replace placeholders in the provided query.
Return Value
A
DITWriteTransactionPendingCursorOperationthat you can use to chain further query-related function calls to update, remove, or evict the documents. -
Generates a
DITWriteTransactionPendingCursorOperationthat can be used to update, remove or evict documents.Declaration
Objective-C
- (nonnull DITWriteTransactionPendingCursorOperation *)findAll;Return Value
A
DITWriteTransactionPendingCursorOperationthat you can use to chain further query-related function calls to update, remove, or evict the documents.
DITScopedWriteTransaction Class Reference