Skip to content

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

fix: update postgrest-js example docs for v2

Alaister Young27546f19dc68
diff --git a/spec/supabase_js_v2_legacy.yml b/spec/supabase_js_v2_legacy.yml
index eed7f3da890..688856e7364 100644
--- a/spec/supabase_js_v2_legacy.yml
+++ b/spec/supabase_js_v2_legacy.yml
@@ -933,10 +933,6 @@ pages:
insert():
title: 'Create data: insert()'
$ref: '@supabase/postgrest-js.PostgrestQueryBuilder.insert'
- notes: |
- - By default, every time you run `insert()`, the client library will make a `select` to return the full record.
- This is convenient, but it can also cause problems if your Policies are not configured to allow the `select` operation.
- If you are using Row Level Security and you are encountering problems, try setting the `returning` param to `minimal`.
examples:
- name: Create a record
isSpotlight: true
@@ -948,37 +944,28 @@ pages:
{ name: 'The Shire', country_id: 554 }
])
```
- - name: Bulk create
- description: |
- When running a bulk create, the operation is handled in a single transaction. If any of the inserts fail, all other operations are
- rolled back.
+ - name: Create a record and return it
js: |
```js
const { data, error } = await supabase
.from('cities')
.insert([
- { name: 'The Shire', country_id: 554 },
- { name: 'Rohan', country_id: 555 },
+ { name: 'The Shire', country_id: 554 }
])
+ .select()
```
- - name: Upsert
+ - name: Bulk create
description: |
- For upsert, if set to true, primary key columns would need to be included
- in the data parameter in order for an update to properly happen. Also, primary keys
- used must be natural, not surrogate. There are however,
- [workarounds](https://github.com/PostgREST/postgrest/issues/1118)
- for surrogate primary keys.
+ When running a bulk create, the operation is handled in a single transaction. If any of the inserts fail, all other operations are
+ rolled back.
js: |
```js
const { data, error } = await supabase
.from('cities')
- .insert(
- [
- { name: 'The Shire', country_id: 554 },
- { name: 'Rohan', country_id: 555 },
- { name: 'City by the Bay', country_id:840}
- ],
- { upsert: true })
+ .insert([
+ { name: 'The Shire', country_id: 554 },
+ { name: 'Rohan', country_id: 555 },
+ ])
```
update():
@@ -1001,7 +988,7 @@ pages:
Postgres offers a
[number of operators](https://www.postgresql.org/docs/current/functions-json.html)
for working with JSON data. Right now it is only possible to update an entire JSON document,
- but we are [working on ideas](https://github.com/PostgREST/postgrest/issues/465) for updating individual keys.
+ but we are [working on ideas](https://github.com/PostgREST/postgrest/issues/465) for updating individual keys. For example:
js: |
```js
const { data, error } = await supabase