2022-04-22 23:29:24 +02:00
|
|
|
package eu.kanade.data
|
|
|
|
|
|
|
|
import androidx.paging.PagingSource
|
|
|
|
import com.squareup.sqldelight.Query
|
|
|
|
import com.squareup.sqldelight.Transacter
|
|
|
|
import eu.kanade.tachiyomi.Database
|
|
|
|
import kotlinx.coroutines.flow.Flow
|
|
|
|
|
|
|
|
interface DatabaseHandler {
|
|
|
|
|
|
|
|
suspend fun <T> await(inTransaction: Boolean = false, block: suspend Database.() -> T): T
|
|
|
|
|
|
|
|
suspend fun <T : Any> awaitList(
|
|
|
|
inTransaction: Boolean = false,
|
2022-05-10 23:54:52 +02:00
|
|
|
block: suspend Database.() -> Query<T>,
|
2022-04-22 23:29:24 +02:00
|
|
|
): List<T>
|
|
|
|
|
|
|
|
suspend fun <T : Any> awaitOne(
|
|
|
|
inTransaction: Boolean = false,
|
2022-05-10 23:54:52 +02:00
|
|
|
block: suspend Database.() -> Query<T>,
|
2022-04-22 23:29:24 +02:00
|
|
|
): T
|
|
|
|
|
|
|
|
suspend fun <T : Any> awaitOneOrNull(
|
|
|
|
inTransaction: Boolean = false,
|
2022-05-10 23:54:52 +02:00
|
|
|
block: suspend Database.() -> Query<T>,
|
2022-04-22 23:29:24 +02:00
|
|
|
): T?
|
|
|
|
|
|
|
|
fun <T : Any> subscribeToList(block: Database.() -> Query<T>): Flow<List<T>>
|
|
|
|
|
|
|
|
fun <T : Any> subscribeToOne(block: Database.() -> Query<T>): Flow<T>
|
|
|
|
|
|
|
|
fun <T : Any> subscribeToOneOrNull(block: Database.() -> Query<T>): Flow<T?>
|
|
|
|
|
|
|
|
fun <T : Any> subscribeToPagingSource(
|
|
|
|
countQuery: Database.() -> Query<Long>,
|
|
|
|
transacter: Database.() -> Transacter,
|
2022-05-10 23:54:52 +02:00
|
|
|
queryProvider: Database.(Long, Long) -> Query<T>,
|
2022-04-22 23:29:24 +02:00
|
|
|
): PagingSource<Long, T>
|
|
|
|
}
|