cachedResult

fun cachedResult(data: String, supabase: SupabaseClient, fetchedAt: Instant, hasPendingMutations: Boolean = false): PostgrestResult(source)

The result of a one-shot read the cache answered, as a fake of the app's own repository returns it: PostgrestResult.isFromCache reads true, PostgrestResult.fetchedAt the time given, to the millisecond, and PostgrestResult.hasPendingMutations the flag given. The library stamps a read's result in headers PostgREST never sends, and this one carries the same stamp; a result built with PostgrestResult(data, Headers.Empty, supabase.postgrest) carries none, and reads as a result supabase-kt returned itself.

Parameters

data

the rows, as the JSON text a read returns.

supabase

a client with Postgrest installed, built on a Ktor MockEngine, since supabase-kt's Postgrest needs a client with an engine.

fetchedAt

when the rows were fetched from the server.

hasPendingMutations

whether a queued write changed a row shown.


fun cachedResult(data: String, supabase: SupabaseClient, fetchedAt: Instant, pendingRowKeys: Set<JsonObject>): PostgrestResult(source)

The result of a one-shot read the cache answered that names the rows a queued write changed: cachedResult, with PostgrestResult.pendingRowKeys reading pendingRowKeys and PostgrestResult.hasPendingMutations reading true exactly when it is not empty.

Parameters

data

the rows, as the JSON text a read returns.

supabase

a client with Postgrest installed, built on a Ktor MockEngine.

fetchedAt

when the rows were fetched from the server.

pendingRowKeys

the primary keys of the rows a queued write added, changed or removed, each an object of the table's key columns.