Skip to content

Latest commit

 

History

History
50 lines (42 loc) · 1.31 KB

README.md

File metadata and controls

50 lines (42 loc) · 1.31 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.0.12-1.0.0")
            }
        }
    }
}

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,
    database,
    mapper,
    queryProvider
)