QueryPagingSource

@JvmName(name = "QueryPagingSourceWithQuery")
fun <RowType : Any> QueryPagingSource(context: CoroutineContext, select: Select, collection: Collection, mapper: (Map<String, Any?>) -> RowType, queryProvider: From.() -> LimitRouter): PagingSource<Int, RowType>
@JvmName(name = "QueryPagingSourceStringWithQuery")
fun <RowType : Any> QueryPagingSource(context: CoroutineContext, select: Select, collection: Collection, mapper: (String) -> RowType, queryProvider: From.() -> LimitRouter): PagingSource<Int, RowType>

Create a PagingSource that pages through results according to queries generated by queryProvider. queryProvider receives a SELECT FROM collection and should append any necessary SQL JOIN, WHERE, ORDER BY, and GROUP BY clauses.

Minimally, an ORDER BY clause should always be provided to ensure query results and paged data are consistently ordered.

Queries returned by queryProvider should expect the PagingSource to do SQL offset/limit based paging. queryProvider will be called multiple times both as a count query for total records as well as with the select statement with page offsets to retrieve documents, which are mapped to objects via the provided mapper.

Queries will be executed on context.

Parameters

context

CoroutineContext to execute queries on

select

query Select statement

collection

collection to query

mapper

mapping function from JSON query results to objects

queryProvider

query provider function


fun <RowType : Any> QueryPagingSource(context: CoroutineContext, select: Select, database: Database, mapper: (Map<String, Any?>) -> RowType): PagingSource<Int, RowType>
@JvmName(name = "QueryPagingSourceString")
fun <RowType : Any> QueryPagingSource(context: CoroutineContext, select: Select, database: Database, mapper: (String) -> RowType): PagingSource<Int, RowType>

Deprecated

Use collection instead of database

Replace with

QueryPagingSource(context, select, database.defaultCollection, mapper) { this }

Create a PagingSource that pages through all results from the database.

Queries will be executed without JOIN, WHERE, ORDER BY, or GROUP BY clauses. Call the version of QueryPagingSource that takes a queryProvider in order to append these clauses to the paging queries.

Minimally, an ORDER BY clause should always be provided to ensure query results and paged data are consistently ordered. It's strongly encouraged to use the queryProvider parameter for this reason.

The PagingSource will do SQL offset/limit based paging. Use the select statement and mapper to map paged documents to objects.

Queries will be executed on context.

Parameters

context

CoroutineContext to execute queries on

select

query Select statement

database

database to query

mapper

mapping function from JSON query results to objects


@JvmName(name = "QueryPagingSourceWithQuery")
fun <RowType : Any> QueryPagingSource(context: CoroutineContext, select: Select, database: Database, mapper: (Map<String, Any?>) -> RowType, queryProvider: From.() -> LimitRouter): PagingSource<Int, RowType>
@JvmName(name = "QueryPagingSourceStringWithQuery")
fun <RowType : Any> QueryPagingSource(context: CoroutineContext, select: Select, database: Database, mapper: (String) -> RowType, queryProvider: From.() -> LimitRouter): PagingSource<Int, RowType>

Deprecated

Use collection instead of database

Replace with

QueryPagingSource(context, select, database.defaultCollection, mapper, queryProvider)

Create a PagingSource that pages through results according to queries generated by queryProvider. queryProvider receives a SELECT FROM database and should append any necessary SQL JOIN, WHERE, ORDER BY, and GROUP BY clauses.

Minimally, an ORDER BY clause should always be provided to ensure query results and paged data are consistently ordered.

Queries returned by queryProvider should expect the PagingSource to do SQL offset/limit based paging. queryProvider will be called multiple times both as a count query for total records as well as with the select statement with page offsets to retrieve documents, which are mapped to objects via the provided mapper.

Queries will be executed on context.

Parameters

context

CoroutineContext to execute queries on

select

query Select statement

database

database to query

mapper

mapping function from JSON query results to objects

queryProvider

query provider function