Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

docs(js): add example for deleting a record and returning it (#26855)

Bobbie Soedirgoea9cfb921a20
diff --git a/apps/docs/spec/supabase_js_v2.yml b/apps/docs/spec/supabase_js_v2.yml
index 9b3610b84c6..36c9820dbfd 100644
--- a/apps/docs/spec/supabase_js_v2.yml
+++ b/apps/docs/spec/supabase_js_v2.yml
@@ -4102,7 +4102,7 @@ functions:
name: Delete a single record
code: |
```ts
- const { error } = await supabase
+ const response = await supabase
.from('countries')
.delete()
.eq('id', 1)
@@ -4128,11 +4128,47 @@ functions:
hideCodeBlock: true
isSpotlight: true
+ - id: delete-records-and-return-it
+ name: Delete a record and return it
+ code: |
+ ```ts
+ const { data, error } = await supabase
+ .from('countries')
+ .delete()
+ .eq('id', 1)
+ .select()
+ ```
+ data:
+ sql: |
+ ```sql
+ create table
+ countries (id int8 primary key, name text);
+
+ insert into
+ countries (id, name)
+ values
+ (1, 'Spain');
+ ```
+ response: |
+ ```json
+ {
+ "data": [
+ {
+ "id": 1,
+ "name": "Spain"
+ }
+ ],
+ "status": 200,
+ "statusText": "OK"
+ }
+ ```
+ hideCodeBlock: true
+
- id: delete-multiple-records
name: Delete multiple records
code: |
```ts
- const { error } = await supabase
+ const response = await supabase
.from('countries')
.delete()
.in('id', [1, 2, 3])
@@ -4155,8 +4191,7 @@ functions:
"statusText": "No Content"
}
```
- hideCodeBlock: false
- isSpotlight: false
+ hideCodeBlock: true
- id: rpc
title: 'Postgres functions: rpc()'