DittoMutableDocument

public class DittoMutableDocument

This is used as part of update operations for documents. It provides access to updating a document through a subscript-based API. A subscript operation returns a DittoMutableDocumentPath that you can then use to chain further subscript operations to in order to access nested values in a document. Once you’ve defined the path to a key in a document that you’d like to update, by using subscripts, then you can use the functionality defined on DittoMutableDocumentPath to perform the desired document update(s). Note that objects of this type should only be used within the scope of the update closure that they are provided in.

  • id

    The ID of the document.

    Declaration

    Swift

    public var id: DittoDocumentID { get }
  • The document’s inner value.

    Declaration

    Swift

    public var value: [String : Any?] { get }
  • Return a typed document where the document’s inner value is decoded into an object of the provided type.

    Throws

    DittoSwiftError.

    Precondition

    The type provided must conform to Codable.

    Declaration

    Swift

    public func typed<T>(_ type: T.Type) throws -> DittoTypedDocument<T> where T : Decodable, T : Encodable

    Parameters

    type

    The type to use to decode the document’s inner value.

    Return Value

    A DittoTypedDocument whose inner value has been decoded into an object of the provided type.

  • Used to specify a path to a key in the document that you can subscript further to access a nested key in the document or perform an update operation on it immediately.

    Declaration

    Swift

    public subscript(key: String) -> DittoMutableDocumentPath { get }

    Parameters

    key

    The initial part of the path needed to get to the key in the document you wish to update.