Skip to content

Commit 6a0728f

Browse files
committed
Add QueryProvider type alias
1 parent 6e6cdc9 commit 6a0728f

File tree

7 files changed

+30
-9
lines changed

7 files changed

+30
-9
lines changed

couchbase-lite-ee-paging/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ val select = select(Meta.id, "type", "name")
3030
val mapper = { json: String ->
3131
Json.decodeFromString<Hotel>(json)
3232
}
33-
val queryProvider: From.() -> LimitRouter = {
33+
val queryProvider: QueryProvider = {
3434
where {
3535
("type" equalTo "hotel") and
3636
("state" equalTo "California")

couchbase-lite-paging/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ val select = select(Meta.id, "type", "name")
3030
val mapper = { json: String ->
3131
Json.decodeFromString<Hotel>(json)
3232
}
33-
val queryProvider: From.() -> LimitRouter = {
33+
val queryProvider: QueryProvider = {
3434
where {
3535
("type" equalTo "hotel") and
3636
("state" equalTo "California")

couchbase-lite-paging/src/commonMain/kotlin/kotbase/paging/OffsetQueryPagingSource.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import kotlin.coroutines.resumeWithException
3333
internal class OffsetQueryPagingSource<RowType : Any>(
3434
private val select: Select,
3535
private val collection: Collection,
36-
private val queryProvider: From.() -> LimitRouter,
36+
private val queryProvider: QueryProvider,
3737
private val context: CoroutineContext,
3838
private val initialOffset: Int,
3939
private val mapMapper: ((Map<String, Any?>) -> RowType)? = null,

couchbase-lite-paging/src/commonMain/kotlin/kotbase/paging/QueryPagingSource.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public fun <RowType : Any> QueryPagingSource(
5858
select: Select,
5959
collection: Collection,
6060
mapper: (Map<String, Any?>) -> RowType,
61-
queryProvider: From.() -> LimitRouter,
61+
queryProvider: QueryProvider,
6262
initialOffset: Int = 0
6363
): PagingSource<Int, RowType> = OffsetQueryPagingSource(
6464
select,
@@ -96,7 +96,7 @@ public fun <RowType : Any> QueryPagingSource(
9696
select: Select,
9797
collection: Collection,
9898
mapper: (String) -> RowType,
99-
queryProvider: From.() -> LimitRouter,
99+
queryProvider: QueryProvider,
100100
initialOffset: Int = 0
101101
): PagingSource<Int, RowType> = OffsetQueryPagingSource(
102102
select,
@@ -138,7 +138,7 @@ public fun <RowType : Any> QueryPagingSource(
138138
select: Select,
139139
database: Database,
140140
mapper: (Map<String, Any?>) -> RowType,
141-
queryProvider: From.() -> LimitRouter,
141+
queryProvider: QueryProvider,
142142
initialOffset: Int = 0
143143
): PagingSource<Int, RowType> = OffsetQueryPagingSource(
144144
select,
@@ -180,7 +180,7 @@ public fun <RowType : Any> QueryPagingSource(
180180
select: Select,
181181
database: Database,
182182
mapper: (String) -> RowType,
183-
queryProvider: From.() -> LimitRouter,
183+
queryProvider: QueryProvider,
184184
initialOffset: Int = 0
185185
): PagingSource<Int, RowType> = OffsetQueryPagingSource(
186186
select,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright 2025 Jeff Lockhart
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package kotbase.paging
17+
18+
import kotbase.From
19+
import kotbase.LimitRouter
20+
21+
public typealias QueryProvider = From.() -> LimitRouter

couchbase-lite-paging/src/commonTest/kotlin/kotbase/paging/OffsetQueryPagingSourceTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ class OffsetQueryPagingSourceTest : BaseDbTest() {
496496

497497
private fun select(): Select = select(Meta.id)
498498

499-
private fun queryProvider(): From.() -> LimitRouter = {
499+
private fun queryProvider(): QueryProvider = {
500500
orderBy { (Meta.id + 0).ascending() }
501501
}
502502

docs/site/paging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ val select = select(Meta.id, "type", "name")
4040
val mapper = { json: String ->
4141
Json.decodeFromString<Hotel>(json)
4242
}
43-
val queryProvider: From.() -> LimitRouter = {
43+
val queryProvider: QueryProvider = {
4444
where {
4545
("type" equalTo "hotel") and
4646
("state" equalTo "California")

0 commit comments

Comments
 (0)