From 8bd805fb92402406ee48ff6e9b9e556a71b474df Mon Sep 17 00:00:00 2001 From: Jan Tennert Date: Thu, 21 Dec 2023 20:35:28 +0100 Subject: [PATCH] Fix missing modifiers entry and invalid syntax in Kotlin docs (#19945) * fix kotlin docs * fix example * Apply suggestions from code review --------- Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> --- spec/supabase_kt_v2.yml | 54 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/spec/supabase_kt_v2.yml b/spec/supabase_kt_v2.yml index e03a2d6c5c0..fa3032605d4 100644 --- a/spec/supabase_kt_v2.yml +++ b/spec/supabase_kt_v2.yml @@ -518,7 +518,7 @@ functions: isSpotlight: true code: | ```kotlin - let toUpsert = User(username = "supabot") + val toUpsert = User(username = "supabot") supabase.from("users").upsert(toUpsert, onConflict = "username") ``` - id: upsert-return-row-count @@ -526,7 +526,7 @@ functions: isSpotlight: true code: | ```kotlin - let toUpsert = User(username = "supabot") + val toUpsert = User(username = "supabot") val count = supabase.from("users").upsert(toUpsert, onConflict = "username") { count(Count.EXACT) }.count() @@ -1963,6 +1963,56 @@ functions: } ``` hideCodeBlock: true + - id: using-modifiers + title: Using Modifiers + description: | + Filters work on the row level—they allow you to return rows that + only match certain conditions without changing the shape of the rows. + Modifiers are everything that don't fit that definition—allowing you to + change the format of the response (e.g., returning a CSV string). + + Modifiers are be specified next to the filter block. Some modifiers only apply for + queries that return rows (e.g., `select()` or `rpc()` on a function that + returns a table response). + - id: db-modifiers-select + title: select() + $ref: '@supabase/postgrest-js.PostgrestTransformBuilder.select' + examples: + - id: with-upsert + name: With `upsert()` + code: | + ```kotlin + val toUpsert = Country(id = 2, name = "Algeria") + val count = supabase.from("countries").upsert(toUpsert) { + select() + }.decodeSingle() + ``` + data: + sql: | + ```sql + create table + countries (id int8 primary key, name text); + + insert into + countries (id, name) + values + (1, 'Afghanistan'); + ``` + response: | + ```json + { + "data": [ + { + "id": 2, + "name": "Algeria" + } + ], + "status": 201, + "statusText": "Created" + } + ``` + hideCodeBlock: true + isSpotlight: true - id: order title: order() description: |