DittoStore

class DittoStore

Provides access to execute Ditto queries, work with DittoCollections and a write transaction API.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun collection(name: String): DittoCollection

Returns a DittoCollection with the provided name.

Link copied to clipboard
fun collectionNames(): List<String>

Returns a list of the names of collections in the store.

Link copied to clipboard
fun collections(): DittoPendingCollectionsOperation

Returns an object that lets you fetch or observe the collections in the store.

Link copied to clipboard
suspend fun execute(query: String, arguments: Map<String, Any?>? = mapOf()): DittoQueryResult

Executes a DQL query and returns items as a query result.

Link copied to clipboard
@JvmName(name = "execute")
fun executeBlocking(query: String, arguments: Map<String, Any?>? = mapOf()): DittoQueryResult

Non-suspend version of execute. Provides a simpler API to Java where Kotlin Coroutines are not typically used.

Link copied to clipboard
fun fetchAttachment(tokenMap: Map<String, Any>, onFetchEvent: (DittoAttachmentFetchEvent) -> Unit): DittoAttachmentFetcher
fun fetchAttachment(tokenMap: Map<String, Any>, fetchEventHandler: DittoAttachmentFetchEventHandler): DittoAttachmentFetcher
fun fetchAttachment(token: DittoAttachmentToken, onFetchEvent: (DittoAttachmentFetchEvent) -> Unit): DittoAttachmentFetcher
fun fetchAttachment(token: DittoAttachmentToken, fetchEventHandler: DittoAttachmentFetchEventHandler): DittoAttachmentFetcher

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

Link copied to clipboard
operator fun get(name: String): DittoCollection

Returns a DittoCollection with the provided name.

Link copied to clipboard
suspend fun newAttachment(inputStream: InputStream, metadata: Map<String, String> = emptyMap()): DittoAttachment
suspend fun newAttachment(path: String, metadata: Map<String, String> = emptyMap()): DittoAttachment

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

Link copied to clipboard
@JvmName(name = "newAttachment")
fun newAttachmentBlocking(inputStream: InputStream, metadata: Map<String, String> = emptyMap()): DittoAttachment
@JvmName(name = "newAttachment")
fun newAttachmentBlocking(path: String, metadata: Map<String, String> = emptyMap()): DittoAttachment

Non-suspend version of newAttachment. Provides a simpler API to Java where Kotlin Coroutines are not typically used.

Link copied to clipboard
fun queriesHash(liveQueries: Array<DittoLiveQuery>): BigInteger

Returns a hash representing the current version of the given queries. When a document matching such queries gets mutated, the hash will change as well.

Link copied to clipboard
fun queriesHashMnemonic(liveQueries: Array<DittoLiveQuery>): String

Returns a sequence of English words representing the current version of the given queries. When a document matching such queries gets mutated, the words will change as well.

Link copied to clipboard
fun registerObserver(    query: String,     arguments: Map<String, Any?>? = null,     changeHandler: DittoChangeHandler): DittoStoreObserver

Convenience method, same as registerObserver where signalNext is called automatically after the changeHandler finishes.

fun registerObserver(    query: String,     arguments: Map<String, Any?>? = null,     changeHandler: DittoChangeHandlerWithNextSignal): DittoStoreObserver

Installs and returns a store observer for a query, configuring Ditto to trigger the passed in change handler whenever documents in the local store change such that the result of the matching query changes. The passed in query must be a SELECT query, otherwise a StoreError with QueryNotSupported reason is thrown.

Link copied to clipboard
fun write(block: (DittoWriteTransaction) -> Unit): List<DittoWriteTransactionResult>
fun write(handler: DittoWriteTransactionHandler): List<DittoWriteTransactionResult>

Allows you to group multiple operations together that affect multiple documents, potentially across multiple collections.

Properties

Link copied to clipboard
var attachmentFetchers: Set<DittoAttachmentFetcher>

All currently active attachment fetchers.

Link copied to clipboard
var observers: Set<DittoStoreObserver>

All currently active store observers.