Postgrest

Plugin to interact with the supabase Postgrest API

To use it you need to install it to the SupabaseClient:

val supabase = createSupabaseClient(supabaseUrl, supabaseKey) {
install(Postgrest)
}

then you can use it like this:

val product = supabase.postgrest["products"].select {
Product::id eq 2
}.decodeSingle<Product>()

Types

Link copied to clipboard
data class Config(var defaultSchema: String = "public", var propertyConversionMethod: PropertyConversionMethod = PropertyConversionMethod.CAMEL_CASE_TO_SNAKE_CASE) : MainConfig, CustomSerializationConfig

Config for the Postgrest plugin

Properties

Link copied to clipboard
abstract val apiVersion: Int
Link copied to clipboard
abstract val config: Postgrest.Config
Link copied to clipboard
abstract val pluginKey: String
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open suspend fun close()
Link copied to clipboard
abstract fun from(table: String): PostgrestQueryBuilder

Creates a new PostgrestQueryBuilder for the given table

abstract fun from(schema: String, table: String): PostgrestQueryBuilder

Creates a new PostgrestQueryBuilder for the given schema and table

Link copied to clipboard
open operator fun get(table: String): PostgrestQueryBuilder

Creates a new PostgrestQueryBuilder for the given schema and table

open operator fun get(schema: String, table: String): PostgrestQueryBuilder

Creates a new PostgrestQueryBuilder for the given table

Link copied to clipboard
open fun init()
Link copied to clipboard
abstract suspend fun parseErrorResponse(response: HttpResponse): RestException
Link copied to clipboard
open fun resolveUrl(path: String): String
Link copied to clipboard
abstract suspend fun rpc(function: String, request: RpcRequestBuilder.() -> Unit = {}): PostgrestResult
abstract suspend fun rpc(function: String, parameters: JsonObject, request: RpcRequestBuilder.() -> Unit = {}): PostgrestResult

Executes a database function

Link copied to clipboard
inline suspend fun <T : Any> Postgrest.rpc(function: String, parameters: T, noinline request: RpcRequestBuilder.() -> Unit = {}): PostgrestResult

Executes a database function