DittoCollection

A reference to a collection in a DittoStore.

  • The name of the collection.

Upsert

  • 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.

Find

  • 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 observeLocal or subscribe if you want to get updates about the document over time. It can also be used to update, remove or evict the document.

  • 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 observeLocal or subscribe if you want to get updates about documents matching the query as they occur. It can also be used to update, remove, or evict documents.

  • Generates a DittoPendingCursorOperation with the provided query and query arguments that can be used to find the documents matching the query at a point in time or you can chain a call to observeLocal or subscribe if you want to get updates about documents matching the query as they occur. It can also 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.

  • 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 observeLocal or subscribe if you want to get updates about documents in the collection over time. It can also be used to update, remove or evict documents.

  • Creates a new attachment, which can then be inserted into a document.

    The file residing at the provided path will be copied into the Ditto’s store. The DITAttachment object that is returned is what you can then use to insert an attachment into a document.

    You can provide metadata about the attachment, which will be replicated to other peers alongside the file attachment.

    Below is a snippet to show how you can use the newAttachment functionality to insert an attachment into a document.

    if let attachment = collection.newAttachment("/path/to/my/file.pdf") {
        let docID = try! collection.insert(["attachment": attachment, "other": "string"])
    }
    
  • Fetch the attachment corresponding to the provided attachment token.