From 7b00aed6e07e8ccdfd214de8c23d1db01cb15471 Mon Sep 17 00:00:00 2001 From: Vinzent Date: Tue, 13 Dec 2022 18:57:34 +0100 Subject: [PATCH] fix(docs): correct code examples for dart ref --- spec/supabase_dart_v1.yml | 53 +++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/spec/supabase_dart_v1.yml b/spec/supabase_dart_v1.yml index 931e511b6f5..84d12e01282 100644 --- a/spec/supabase_dart_v1.yml +++ b/spec/supabase_dart_v1.yml @@ -504,7 +504,7 @@ functions: isSpotlight: true code: | ```dart - final data = await supabase + await supabase .from('cities') .insert({'name': 'The Shire', 'country_id': 554}); ``` @@ -512,10 +512,21 @@ functions: name: Bulk create code: | ```dart - final res = await supabase.from('cities').insert([ + final List> data = + await supabase.from('cities').insert([ {'name': 'The Shire', 'country_id': 554}, {'name': 'Rohan', 'country_id': 555}, - ]); + ]).select(); + ``` + - id: fetch-inserted-data + name: Fetch inserted record + code: | + ```dart + final List> data = + await supabase.from('cities').insert([ + {'name': 'The Shire', 'country_id': 554}, + {'name': 'Rohan', 'country_id': 555}, + ]).select(); ``` - id: update @@ -526,17 +537,17 @@ functions: - `update()` should always be combined with [Filters](/docs/reference/dart/using-filters) to target the item(s) you wish to update. examples: - id: updating-your-data - name: Updating your data + name: Update your data isSpotlight: true code: | ```dart - final data = await supabase + await supabase .from('cities') .update({ 'name': 'Middle Earth' }) .match({ 'name': 'Auckland' }); ``` - id: updating-json-data - name: Updating JSON data + name: Update JSON data description: | Postgres offers a [number of operators](https://www.postgresql.org/docs/current/functions-json.html) @@ -544,7 +555,7 @@ functions: but we are [working on ideas](https://github.com/PostgREST/postgrest/issues/465) for updating individual keys. code: | ```dart - final data = await supabase + await supabase .from('users') .update({ 'address': { @@ -554,6 +565,18 @@ functions: }) .eq('address->postcode', 90210); ``` + - id: fetch-updated-rows + name: Fetch updated rows + code: | + ```dart + final List> data = await supabase + .from('users') + .update({ + 'address': {'street': 'Melrose Place', 'postcode': 90210} + }) + .eq('address->postcode', 90210) + .select(); + ``` - id: upsert description: | @@ -568,7 +591,7 @@ functions: isSpotlight: true code: | ```dart - final data = await supabase + await supabase .from('messages') .upsert({ 'id': 3, 'message': 'foo', 'username': 'supabot' }); ``` @@ -581,7 +604,7 @@ functions: isSpotlight: true code: | ```dart - final data = await supabase + await supabase .from('users') .upsert({ 'username': 'supabot' }, { 'onConflict': 'username' }); ``` @@ -612,11 +635,21 @@ functions: isSpotlight: true code: | ```dart - final data = await supabase + await supabase .from('cities') .delete() .match({ 'id': 666 }); ``` + - id: fetch-delete-records + name: Fetch deleted records + code: | + ```dart + final List> data = await supabase + .from('cities') + .delete() + .match({ 'id': 666 }) + .select(); + ``` - id: rpc title: 'Stored Procedures: rpc()'