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: String { get }
-
Insert a document into the scoped collection.
Throws
DittoSwiftError
Declaration
Swift
@discardableResult public func insert( _ content: [String: Any?], withID id: DittoDocumentID? = nil, isDefault: Bool = false ) throws -> DittoDocumentID
Parameters
document
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 isfalse
.Return Value
The ID of the inserted document.
-
Insert a document into the scoped collection.
Throws
DittoSwiftError
Declaration
Swift
@discardableResult public func insert<T: Codable>( _ content: T, withID id: DittoDocumentID? = nil, isDefault: Bool = false ) throws -> DittoDocumentID
Parameters
document
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 isfalse
.Return Value
The ID of the inserted document.
-
Generates a
DittoWriteTransactionPendingIDSpecificOperation
with the provided document ID that can be used to update, remove, or evict the document.Throws
DittoSwiftError
.Declaration
Swift
public func findByID(_ id: DittoDocumentID) -> DittoWriteTransactionPendingIDSpecificOperation
Parameters
id
The ID of the document.
Return Value
A
DittoWriteTransactionPendingIDSpecificOperation
that you can chain function calls to update, remove, or evict the document. -
Generates a
DittoWriteTransactionPendingCursorOperation
with the provided query that can be used to update, remove, or evict documents.Declaration
Swift
public func find(query: String) -> DittoWriteTransactionPendingCursorOperation
Parameters
query
The query to run against the collection.
Return Value
A
DittoWriteTransactionPendingCursorOperation
that you can use to chain further query-related function calls to update, remove, or evict the documents. -
Generates a
DittoWriteTransactionPendingCursorOperation
that can be used to update, remove or evict documents.Declaration
Swift
public func findAll() -> DittoWriteTransactionPendingCursorOperation
Return Value
A
DittoWriteTransactionPendingCursorOperation
that you can use to chain further query-related function calls to update, remove, or evict the documents.