Skip to content

Latest commit

 

History

History
49 lines (41 loc) · 1.28 KB

README.md

File metadata and controls

49 lines (41 loc) · 1.28 KB

Module couchbase-lite-paging

Couchbase Lite Community Edition – Paging Extensions

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

kotlin {
    sourceSets {
        commonMain.dependencies {
            implementation("dev.kotbase:couchbase-lite-paging:3.1.9-1.1.1")
        }
    }
}

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
)