Paging
The paging extensions are built on Cash App's Multiplatform Paging,
Google's AndroidX Paging with
multiplatform support. Kotbase Paging provides a PagingSource
which performs limit/offset paging queries
based on a user-supplied database query.
Installation
Usage
// Uses kotlinx-serialization JSON processor
@Serializable
data class Hotel(val id: String, val type: String, val name: String)
val select = select(Meta.id, "type", "name")
val mapper = { json: String ->
Json.decodeFromString<Hotel>(json)
}
val queryProvider: From.() -> LimitRouter = {
where {
("type" equalTo "hotel") and
("state" equalTo "California")
}
.orderBy { "name".ascending() }
}
val pagingSource = QueryPagingSource(
EmptyCoroutineContext,
select,
collection,
mapper,
queryProvider
)