mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-13 05:52:48 +01:00
b1f46ed830
* Migrate History screen database call to SQLDelight - Move all migrations to SQLDelight - Move all tables to SQLDelight Co-authored-by: inorichi <3521738+inorichi@users.noreply.github.com> * Changes from review comments * Add adapters to database * Remove logging of database version in App * Change query name for paging source queries * Update migrations * Make SQLite Callback handle migration - To ensure it updates the database * Use SQLDelight Schema version for Callback database version Co-authored-by: inorichi <3521738+inorichi@users.noreply.github.com>
40 lines
1.2 KiB
Kotlin
40 lines
1.2 KiB
Kotlin
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,
|
|
block: suspend Database.() -> Query<T>
|
|
): List<T>
|
|
|
|
suspend fun <T : Any> awaitOne(
|
|
inTransaction: Boolean = false,
|
|
block: suspend Database.() -> Query<T>
|
|
): T
|
|
|
|
suspend fun <T : Any> awaitOneOrNull(
|
|
inTransaction: Boolean = false,
|
|
block: suspend Database.() -> Query<T>
|
|
): 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,
|
|
queryProvider: Database.(Long, Long) -> Query<T>
|
|
): PagingSource<Long, T>
|
|
}
|