Query

interface Query<T : Any>

A lazy query. Functions in this class should be handled as if they are operating on cold Flows.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract fun asFlow(): Flow<T>

Executes the query and returns the values as a Flow.

Link copied to clipboard
open suspend fun count(): Long

Returns the amount of values that match this query.

Link copied to clipboard
abstract suspend fun remove()

Removes all the values that match this query.

Link copied to clipboard
open suspend fun single(): T

Returns the only value that matches against this query, or throws an Exception on no or multiple matches.

Link copied to clipboard
open suspend fun singleOrNull(): T?

Returns the only value that matches against this query if present, null if no, or throws a Exception.

Link copied to clipboard
open suspend fun toCollection(): Collection<T>

Executes the query and returns the values as a Collection.

Link copied to clipboard
abstract suspend fun update(mapper: suspend (T) -> T)

Applies the mapper to the values that match against this query. Returning a value with a different DataDescription.indexField value will result in an Exception being thrown.