ditto-lib / live.ditto / DittoCollection

DittoCollection

class DittoCollection

A reference to a collection in a DittoStore.

Constructors

<init>

DittoCollection(name: String, siteID: Long, dittoHandle: SWIGTYPE_p_Ditto, objectMapper: ObjectMapper)

A reference to a collection in a DittoStore.

Properties

name

val name: String

the name of the collection.

Functions

fetchAttachment

fun fetchAttachment(token: DittoAttachmentToken, onStatusChanged: (DittoAttachmentStatus) -> Unit): DittoAttachmentFetcher
fun fetchAttachment(token: DittoAttachmentToken, statusChangeHandler: DittoAttachmentStatusChangeHandler): DittoAttachmentFetcher

Trigger an attachment to be downloaded locally to the device and observe its progress as it does so.

find

fun find(query: String): DittoPendingCursorOperation

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.

findAll

fun findAll(): DittoPendingCursorOperation

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.

findByID

fun findByID(id: String): DittoPendingIDSpecificOperation

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.

insert

fun <T : Any> insert(value: T, id: String? = null, isDefault: Boolean = false): String

Inserts a new document into the collection and returns the document's ID.

newAttachment

fun newAttachment(path: String, metadata: Map<String, String> = emptyMap()): DittoAttachment?
fun newAttachment(inputStream: InputStream, metadata: Map<String, String> = emptyMap()): DittoAttachment?

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