DittoCollection

@objc
public class DittoCollection : NSObject

A reference to a collection in a DittoStore.

  • The name of the collection.

    Declaration

    Swift

    public let name: String
  • Inserts a new document into the collection and returns its assigned ID.

    Throws

    DittoKitError.

    Precondition

    The document content to insert must conform to Codable.

    Declaration

    Swift

    @discardableResult
    public func insert<T>(_ content: T, isDefault: Bool = false) throws -> String where T : Decodable, T : Encodable

    Parameters

    content

    The new document to insert.

    isDefault

    Represents whether or not the data being inserted should be treated as default data or not.

    Return Value

    The ID of the inserted document.

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

    Throws

    DittoKitError.

    Declaration

    Swift

    @discardableResult
    public func insert(_ content: [String : Any?], isDefault: Bool = false) throws -> String

    Parameters

    content

    The new document to insert.

    isDefault

    Represents whether or not the data being inserted should be treated as default data or not.

    Return Value

    The ID of the inserted document.

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

    Throws

    DittoKitError.

    Declaration

    Swift

    @discardableResult
    @objc
    public func insert(_ content: [String : Any], isDefault: Bool = false) throws -> String

    Parameters

    content

    The new document to insert.

    isDefault

    Represents whether or not the data being inserted should be treated as default data or not.

    Return Value

    The ID of the inserted document.

  • Generates a DittoPendingIDSpecificOperation with the provided document ID that can be used to find the document at a point in time or you can chain a call to observe, observeLocal, or subscribe if you want to get updates about the document over time.

    Throws

    DittoKitError.

    Declaration

    Swift

    public func findByID(_ _id: String) throws -> DittoPendingIDSpecificOperation<[String : Any?]>

    Parameters

    _id

    The _id of the document.

    Return Value

    A DittoPendingIDSpecificOperation that you can chain function calls to either get the document immediately or get updates about it over time.

  • Generates a DittoPendingIDSpecificOperation with the provided document ID that can be used to find the document at a point in time or you can chain a call to observe, observeLocal, or subscribe if you want to get updates about the document over time.

    Throws

    DittoKitError.

    Precondition

    The type T that will be decoded as part of the DittoDocument must conform to Codable.

    Declaration

    Swift

    public func findByID<T: Codable>(
        _ _id: String,
        valueType type: T.Type
    ) throws -> DittoPendingIDSpecificOperation<T>

    Parameters

    _id

    The _id of the document.

    valueType

    The type of the value stored in the typed document.

    Return Value

    A DittoPendingIDSpecificOperation that you can chain function calls to either get the document immediately or get updates about it over time.

  • Generates a DittoPendingCursorOperation with the provided query that can be used to find the documents matching the query at a point in time or you can chain a call to observe, observeLocal, or subscribe if you want to get updates about documents matching the query as they occur.

    Throws

    DittoKitError.

    Declaration

    Swift

    public func find(_ query: String) throws -> DittoPendingCursorOperation<[String : Any?]>

    Parameters

    query

    The query to run against the collection.

    Return Value

    A PendingCursorOperation that you can use to chain further query-related function calls.

  • Generates a DittoPendingCursorOperation with the provided query that can be used to find the documents matching the query at a point in time or you can chain a call to observe, observeLocal, or subscribe if you want to get updates about documents matching the query as they occur.

    Throws

    DittoKitError.

    Precondition

    The type T that will be decoded as part of the DittoDocument<T>s must conform to Decodable.

    Declaration

    Swift

    public func find<T: Decodable>(
        _ query: String,
        valueType type: T.Type
    ) throws -> DittoPendingCursorOperation<T>

    Parameters

    query

    The query to run against the collection.

    valueType

    The type of the value stored in the typed document.

    Return Value

    A PendingCursorOperation that you can use to chain further query-related function calls.

  • Generates a DittoPendingCursorOperation that can be used to find all documents in the collection at a point in time or you can chain a call to observe, observeLocal, or subscribe if you want to get updates about documents in the collection over time.

    Throws

    DittoKitError

    Declaration

    Swift

    public func findAll() throws -> DittoPendingCursorOperation<[String : Any?]>

    Return Value

    A DittoPendingCursorOperation that you can use to chain further query-related function calls.

  • Generates a DittoPendingCursorOperation that can be used to find all documents in the collection at a point in time or you can chain a call to observe, observeLocal, or subscribe if you want to get updates about documents in the collection over time.

    Throws

    DittoKitError

    Declaration

    Swift

    public func findAll<T: Codable>(
        valueType type: T.Type
    ) throws -> DittoPendingCursorOperation<T>

    Parameters

    valueType

    The type of the DittoDocument‘s value that should be used when decoding.

    Return Value

    A DittoPendingCursorOperation that you can use to chain further query-related function calls.

  • Update a document with the values provided.

    Throws

    DittoKitError

    Declaration

    Swift

    public func updateByID(_ _id: String, with newDocument: [String : Any?]) throws

    Parameters

    _id

    The ID of the document to update.

    newDocument

    A dictionary representation of the updates to make to the document.

  • Update a document with the values provided as part of the new value.

    Throws

    DittoKitError

    Precondition

    The type T that will be decoded as part of the DittoDocument<T> must conform to Decodable.

    Declaration

    Swift

    public func updateByID<T>(_ _id: String, with newValue: T) throws where T : Decodable, T : Encodable

    Parameters

    _id

    The ID of the document to update.

    newValue

    The object representing the new state of the DittoDocument‘s value.