The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Adds an upsert method
Paul Copplestoneda2b2e760f87
diff --git a/web/sidebar_spec_supabase.js b/web/sidebar_spec_supabase.jsindex c51bdf7b18e..5b044225226 100644--- a/web/sidebar_spec_supabase.js+++ b/web/sidebar_spec_supabase.js@@ -15,7 +15,7 @@ module.exports = {{type: 'category',label: 'Data',- items: ['reference/javascript/select', 'reference/javascript/insert', 'reference/javascript/update', 'reference/javascript/delete', 'reference/javascript/rpc'],+ items: ['reference/javascript/select', 'reference/javascript/insert', 'reference/javascript/update', 'reference/javascript/upsert', 'reference/javascript/delete', 'reference/javascript/rpc'],collapsed: true,},{diff --git a/web/spec/supabase.yml b/web/spec/supabase.ymlindex d105a4a083e..8110baa9581 100644--- a/web/spec/supabase.yml+++ b/web/spec/supabase.yml@@ -44,6 +44,7 @@ info:- select()- insert()- update()+ - upsert()- delete()- rpc()- name: 'Realtime'@@ -558,6 +559,43 @@ pages:.eq('address->postcode', 90210)```+ upsert():+ title: 'Upsert data: upsert()'+ $ref: '@supabase/postgrest-js."lib/PostgrestQueryBuilder".PostgrestQueryBuilder.upsert'+ notes: |+ - Primary keys should to be included in the data payload in order for an update to work correctly.+ - Primary keys must be natural, not surrogate. There are however, [workarounds](https://github.com/PostgREST/postgrest/issues/1118) for surrogate primary keys.+ examples:+ - name: Upsert your data+ isSpotlight: true+ js: |+ ```js+ const { data, error } = await supabase+ .from('messages')+ .upsert({ id: 3, message: 'foo', username: 'supabot' })+ ```+ - name: Upserting into tables with constraints+ isSpotlight: true+ js: |+ ```js+ const { data, error } = await supabase+ .from('users')+ .upsert({ username: 'supabot' }, { onConflict: 'username' })+ ```+ - name: Return the exact number of rows+ isSpotlight: true+ js: |+ ```js+ const { data, error, count } = await supabase+ .from('users')+ .upsert({+ id: 3, message: 'foo',+ username: 'supabot'+ }, {+ count: 'exact'+ })+ ```+delete():title: 'Delete data: delete()'$ref: '@supabase/postgrest-js."lib/PostgrestQueryBuilder".PostgrestQueryBuilder.delete'