supabase-community / supabase-kt

A Kotlin Multiplatform Client for Supabase.
https://supabase.com/docs/reference/kotlin/introduction
MIT License
421 stars 38 forks source link

Extract optional PostgREST properties and add schema support for RPC. #716

Closed jan-tennert closed 2 months ago

jan-tennert commented 2 months ago

What kind of change does this PR introduce?

Feature (closes #713)

What is the current behavior?

Optional properties like defaultToNull for inserting or head for selecting are a function parameter. In increasing numbers, these function parameters get too clunky and as there are already some parameters in the DSL builder (PostgrestRequestBuilder), moving these properties would fit more.

What is the new behavior?

The Select, Insert and Upsert methods now have their own DSL inheriting from the base builder and adding these "old" function parameters. The syntax now looks like this:

supabase.from("table").select {
    head = true
}
supabase.from("table").upsert(myValue) {
    defaultToNull = false
    ignoreDuplicates = false
}
supabase.postgrest.rpc("function") {
    method = RpcMethod.GET
    schema = "mySchema"
}

Additional context

Add any other context or screenshots.