DittoScopedWriteTransaction
public class DittoScopedWriteTransaction
DittoScopedWriteTransaction exposes functionality that allows you to perform multiple operations on the store
within a single write transaction.
-
The name of the collection that the scoped write transaction is scoped to.
Declaration
Swift
public var collectionName: DittoCollectionName { get } -
Inserts a new document into the collection and returns its ID. If the document already exists, the behavior is determined by the given
writeStrategy.Throws
DittoSwiftError.Declaration
Swift
@discardableResult public func upsert( _ content: [String: Any?], writeStrategy: DittoWriteStrategy = .merge ) throws -> DittoDocumentIDParameters
documentThe document to insert.
writeStrategySpecifies the desired strategy for inserting a document. Defaults to
.merge.Return Value
The ID of the inserted document.
-
Inserts a new document into the collection and returns its ID. If the document already exists, the behavior is determined by the given
writeStrategy.Throws
DittoSwiftError.Declaration
Swift
@discardableResult public func upsert<T: Codable>( _ content: T, writeStrategy: DittoWriteStrategy = .merge ) throws -> DittoDocumentIDParameters
documentThe document to insert.
writeStrategySpecifies the desired strategy for inserting a document. The default value is
.merge.Return Value
The ID of the inserted document.
-
Insert a document into the scoped collection.
Throws
DittoSwiftError.Declaration
Swift
@available(*, deprecated, message: "use `upsert(﹚` instead") @discardableResult public func insert( _ content: [String: Any?], withID id: DittoDocumentID? = nil, isDefault: Bool = false ) throws -> DittoDocumentIDParameters
documentThe document to insert.
idThe ID to use for the document. If null then 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.Return Value
The ID of the inserted document.
-
Insert a document into the scoped collection.
Throws
DittoSwiftError.Declaration
Swift
@available(*, deprecated, message: "use `upsert(﹚` instead") @discardableResult public func insertWithStrategy( _ content: [String: Any?], id: DittoDocumentID? = nil, writeStrategy: DittoWriteStrategy = .overwrite ) throws -> DittoDocumentIDParameters
documentThe document to insert.
idThe ID to use for the document. If null then Ditto will automatically assign an ID.
writeStrategySpecifies the desired strategy for inserting a document. The default value is
.overwrite.Return Value
The ID of the inserted document.
-
Insert a document into the scoped collection.
Throws
DittoSwiftError.Declaration
Swift
@available(*, deprecated, message: "use `upsert(﹚` instead") @discardableResult public func insert<T: Codable>( _ content: T, withID id: DittoDocumentID? = nil, isDefault: Bool = false ) throws -> DittoDocumentIDParameters
documentThe document to insert.
idThe ID to use for the document. If null then 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.Return Value
The ID of the inserted document.
-
Insert a document into the scoped collection.
Throws
DittoSwiftError.Declaration
Swift
@available(*, deprecated, message: "use `upsert(﹚` instead") @discardableResult public func insertWithStrategy<T: Codable>( _ content: T, id: DittoDocumentID? = nil, writeStrategy: DittoWriteStrategy = .overwrite ) throws -> DittoDocumentIDParameters
documentThe document to insert.
idThe ID to use for the document. If null then Ditto will automatically assign an ID.
writeStrategySpecifies the desired strategy for inserting a document. The default value is
.overwrite.Return Value
The ID of the inserted document.
-
Generates a
DittoWriteTransactionPendingIDSpecificOperationwith the provided document ID that can be used to update, remove, or evict the document.Throws
DittoSwiftError.Declaration
Swift
public func findByID(_ id: DittoDocumentID) -> DittoWriteTransactionPendingIDSpecificOperationParameters
idThe ID of the document.
Return Value
A
DittoWriteTransactionPendingIDSpecificOperationthat you can chain function calls to update, remove, or evict the document. -
Generates a
DittoWriteTransactionPendingIDSpecificOperationwith the provided document ID that can be used to update, remove, or evict the document.Throws
DittoSwiftError.Declaration
Swift
public func findByID(_ id: Any) -> DittoWriteTransactionPendingIDSpecificOperationParameters
idThe ID of the document.
Return Value
A
DittoWriteTransactionPendingIDSpecificOperationthat you can chain function calls to update, remove, or evict the document. -
Generates a
DittoWriteTransactionPendingCursorOperationwith the provided query that can be used to update, remove, or evict documents.Declaration
Swift
@available(*, deprecated, message: "use the version of `find` that doesn't require an argument label instead") public func find(query: String) -> DittoWriteTransactionPendingCursorOperationParameters
queryThe query to run against the collection.
Return Value
A
DittoWriteTransactionPendingCursorOperationthat you can use to chain further query-related function calls to update, remove, or evict the documents. -
Generates a
DittoWriteTransactionPendingCursorOperationwith the provided query that can be used to update, remove, or evict documents.Declaration
Swift
public func find(_ query: String) -> DittoWriteTransactionPendingCursorOperationParameters
queryThe query to run against the collection.
Return Value
A
DittoWriteTransactionPendingCursorOperationthat you can use to chain further query-related function calls to update, remove, or evict the documents. -
Generates a
DittoWriteTransactionPendingCursorOperationwith the provided query and query arguments that can be used to update, remove, or evict documents.This is the recommended function 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
Swift
public func find(_ query: String, args queryArgs: Dictionary<String, Any?>) -> DittoWriteTransactionPendingCursorOperationParameters
queryThe query to run against the collection.
queryArgsThe arguments to use to replace placeholders in the provided query.
Return Value
A
DittoWriteTransactionPendingCursorOperationthat you can use to chain further query-related function calls to update, remove, or evict the documents. -
Generates a
DittoWriteTransactionPendingCursorOperationthat can be used to update, remove or evict documents.Declaration
Swift
public func findAll() -> DittoWriteTransactionPendingCursorOperationReturn Value
A
DittoWriteTransactionPendingCursorOperationthat you can use to chain further query-related function calls to update, remove, or evict the documents.
DittoScopedWriteTransaction Class Reference