update permissions needed for copy

This commit is contained in:
Inian committed 2022-08-22 16:42:13 +08:00
1 parent 8c4a92ac27
commit 0fe4dd96d8
5 files changed
+109 -109

No files matched your search

@@ -66,7 +66,7 @@ The new file path, including the new file name. For example `folder/image-copy.p
- Policy permissions required:
- `buckets` permissions: none
- `objects` permissions: `update` and `select`
- `objects` permissions: `insert` and `select`
## Examples
@@ -66,7 +66,7 @@ The new file path, including the new file name. For example `folder/image-copy.p
- Policy permissions required:
- `buckets` permissions: none
- `objects` permissions: `update` and `select`
- `objects` permissions: `insert` and `select`
## Examples
+21 -21
View File
@@ -41,7 +41,7 @@ functions:
```js
import { createClient } from '@supabase/supabase-js'
// Create a single supabase client for interacting with your database
// Create a single supabase client for interacting with your database
const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key')
```
- id: example-init-with-params
@@ -62,7 +62,7 @@ functions:
- id: example-init-scheams
summary: API schemas
description: |
By default the API server points to the `public` schema. You can enable other database schemas within the Dashboard.
By default the API server points to the `public` schema. You can enable other database schemas within the Dashboard.
Go to `Settings > API > Schema` and add the schema which you want to expose to the API.
Note: each client connection can only access a single schema, so the code above can access the `other_schema` schema but cannot access the `public` schema.
@@ -71,22 +71,22 @@ functions:
import { createClient } from '@supabase/supabase-js'
// Provide a custom schema. Defaults to "public".
const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key', {
schema: 'other_schema'
const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key', {
schema: 'other_schema'
})
```
- id: example-init-fetch
summary: Custom `fetch` implementation
description: |
`supabase-js` uses the [`cross-fetch`](https://www.npmjs.com/package/cross-fetch) library to make HTTP requests,
but an alternative `fetch` implementation can be provided as an option.
`supabase-js` uses the [`cross-fetch`](https://www.npmjs.com/package/cross-fetch) library to make HTTP requests,
but an alternative `fetch` implementation can be provided as an option.
This is most useful in environments where `cross-fetch` is not compatible (for instance Cloudflare Workers).
code: |
```js
import { createClient } from '@supabase/supabase-js'
const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key', {
fetch: fetch.bind(globalThis)
const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key', {
fetch: fetch.bind(globalThis)
})
```
@@ -128,8 +128,8 @@ functions:
password: 'example-password',
},
{
data: {
first_name: 'John',
data: {
first_name: 'John',
age: 27,
}
}
@@ -203,10 +203,10 @@ functions:
- id: example-signin-redirect
summary: Sign in with redirect.
description: |
Note that the `redirectTo` param is only relevant for OAuth logins, where the login flow is managed by
Note that the `redirectTo` param is only relevant for OAuth logins, where the login flow is managed by
the Auth server. If you are using email/phone logins you should set up your own redirects (within the email/sms template).
Sometimes you want to control where the user is redirected to after they are logged in. Supabase supports this for
Sometimes you want to control where the user is redirected to after they are logged in. Supabase supports this for
any URL path on your website (the URL must either be on the same domain as your Site URL [see Auth>Settings in dashboard], or must match one of the Additional Redirect URLs [also in Auth>Settings]).
code: |
```js
@@ -294,7 +294,7 @@ functions:
To toggle this behavior off and only send a single confirmation link to the new email, toggle "Double confirm email changes" under "Authentication" -> "Settings" off.
User metadata: It's generally better to store user data in a table inside your public schema (i.e. `public.users`).
User metadata: It's generally better to store user data in a table inside your public schema (i.e. `public.users`).
Use the `update()` method if you have data which rarely changes or is specific only to the logged in user.
examples:
- id: example-auth-update-email
@@ -314,8 +314,8 @@ functions:
summary: Update a user's metadata.
code: |
```js
const { user, error } = await supabase.auth.update({
data: { hello: 'world' }
const { user, error } = await supabase.auth.update({
data: { hello: 'world' }
})
```
@@ -330,9 +330,9 @@ functions:
```js
function apiFunction(req, res) {
// Assuming the access token was sent as a header "X-Supabase-Auth"
const { access_token } = req.get('X-Supabase-Auth')
const { access_token } = req.get('X-Supabase-Auth')
// You can now use it within a Supabase Client
// You can now use it within a Supabase Client
const supabase = createClient("https://xyzcompany.supabase.co", "public-anon-key")
const { user, error } = supabase.auth.setAuth(access_token)
@@ -367,9 +367,9 @@ functions:
* Use the Auth token in your server-side function.
*/
async function apiFunction(req, res) {
const { access_token } = req.get('X-Supabase-Auth')
const { access_token } = req.get('X-Supabase-Auth')
// You can now use it within a Supabase Client
// You can now use it within a Supabase Client
const supabase = createClient("https://xyzcompany.supabase.co", "public-anon-key")
const { user, error } = supabase.auth.setAuth(access_token)
@@ -1410,7 +1410,7 @@ functions:
description: |
- Policy permissions required:
- `buckets` permissions: none
- `objects` permissions: `update` and `select`
- `objects` permissions: `insert` and `select`
examples:
- id: example-storage-file-copy
summary: Copy file
+85 -85
View File
@@ -18,7 +18,7 @@ info:
pages:
Installing:
description: |
All JavaScript libraries are built directly by the Supabase team.
All JavaScript libraries are built directly by the Supabase team.
Other languages are built by the community and supported by Supabase.
@@ -34,7 +34,7 @@ pages:
yarn add @supabase/supabase-js
```
Find the source code on [GitHub](https://github.com/supabase/supabase-js).
Find the source code on [GitHub](https://github.com/supabase/supabase-js).
Or via CDN
```js
@@ -57,7 +57,7 @@ pages:
```js
import { createClient } from '@supabase/supabase-js'
// Create a single supabase client for interacting with your database
// Create a single supabase client for interacting with your database
const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key')
```
- name: With additional parameters
@@ -80,12 +80,12 @@ pages:
import { createClient } from '@supabase/supabase-js'
// Provide a custom schema. Defaults to "public".
const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key', {
schema: 'other_schema'
const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key', {
schema: 'other_schema'
})
```
By default the API server points to the `public` schema. You can enable other database schemas within the Dashboard.
By default the API server points to the `public` schema. You can enable other database schemas within the Dashboard.
Go to `Settings > API > Schema` and add the schema which you want to expose to the API.
Note: each client connection can only access a single schema, so the code above can access the `other_schema` schema but cannot access the `public` schema.
@@ -94,13 +94,13 @@ pages:
```js
import { createClient } from '@supabase/supabase-js'
const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key', {
fetch: fetch.bind(globalThis)
const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key', {
fetch: fetch.bind(globalThis)
})
```
`supabase-js` uses the [`cross-fetch`](https://www.npmjs.com/package/cross-fetch) library to make HTTP requests,
but an alternative `fetch` implementation can be provided as an option.
`supabase-js` uses the [`cross-fetch`](https://www.npmjs.com/package/cross-fetch) library to make HTTP requests,
but an alternative `fetch` implementation can be provided as an option.
This is most useful in environments where `cross-fetch` is not compatible (for instance Cloudflare Workers).
Generating Types:
@@ -111,7 +111,7 @@ pages:
`supabase-js` ships with type definitions for usage with TypeScript and for convenient IntelliSense auto-complete and documentation in your editor.
When using TypeScript, you can pass the type of database row as a type parameter to the `from` method to get better auto-completion support down the chain.
When using TypeScript, you can pass the type of database row as a type parameter to the `from` method to get better auto-completion support down the chain.
If you don't provide a type for the row you need to explicitly pass `from<any>('tableName')`.
```ts
@@ -170,8 +170,8 @@ pages:
password: 'example-password',
},
{
data: {
first_name: 'John',
data: {
first_name: 'John',
age: 27,
}
}
@@ -244,10 +244,10 @@ pages:
```
- name: Sign in with redirect.
description: |
Note that the `redirectTo` param is only relevant for OAuth logins, where the login flow is managed by
Note that the `redirectTo` param is only relevant for OAuth logins, where the login flow is managed by
the Auth server. If you are using email/phone logins you should set up your own redirects (within the email/sms template).
Sometimes you want to control where the user is redirected to after they are logged in. Supabase supports this for
Sometimes you want to control where the user is redirected to after they are logged in. Supabase supports this for
any URL path on your website (the URL must either be on the same domain as your Site URL [see Auth>Settings in dashboard], or must match one of the Additional Redirect URLs [also in Auth>Settings]).
js: |
```js
@@ -333,7 +333,7 @@ pages:
To toggle this behavior off and only send a single confirmation link to the new email, toggle "Double confirm email changes" under "Authentication" -> "Settings" off.
User metadata: It's generally better to store user data in a table inside your public schema (i.e. `public.users`).
User metadata: It's generally better to store user data in a table inside your public schema (i.e. `public.users`).
Use the `update()` method if you have data which rarely changes or is specific only to the logged in user.
examples:
- name: Update email for authenticated user.
@@ -353,8 +353,8 @@ pages:
isSpotlight: true
js: |
```js
const { user, error } = await supabase.auth.update({
data: { hello: 'world' }
const { user, error } = await supabase.auth.update({
data: { hello: 'world' }
})
```
@@ -369,9 +369,9 @@ pages:
```js
function apiFunction(req, res) {
// Assuming the access token was sent as a header "X-Supabase-Auth"
const { access_token } = req.get('X-Supabase-Auth')
const { access_token } = req.get('X-Supabase-Auth')
// You can now use it within a Supabase Client
// You can now use it within a Supabase Client
const supabase = createClient("https://xyzcompany.supabase.co", "public-anon-key")
const { user, error } = supabase.auth.setAuth(access_token)
@@ -406,9 +406,9 @@ pages:
* Use the Auth token in your server-side function.
*/
async function apiFunction(req, res) {
const { access_token } = req.get('X-Supabase-Auth')
const { access_token } = req.get('X-Supabase-Auth')
// You can now use it within a Supabase Client
// You can now use it within a Supabase Client
const supabase = createClient("https://xyzcompany.supabase.co", "public-anon-key")
const { user, error } = supabase.auth.setAuth(access_token)
@@ -727,8 +727,8 @@ pages:
js: |
```js
const { data: user, error } = await supabase.functions.invoke('hello', {
headers: {
"my-custom-header": 'my-custom-header-value'
headers: {
"my-custom-header": 'my-custom-header-value'
},
body: JSON.stringify({ foo: 'bar' })
})
@@ -779,11 +779,11 @@ pages:
For more details, [follow the link](https://postgrest.org/en/latest/api.html#embedding-through-join-tables).
- name: Query the same foreign table multiple times
description: |
Sometimes you will need to query the same foreign table twice.
In this case, you can use the name of the joined column to identify
which join you intend to use. For convenience, you can also give an
alias for each column. For example, if we had a shop of products,
and we wanted to get the supplier and the purchaser at the same time
Sometimes you will need to query the same foreign table twice.
In this case, you can use the name of the joined column to identify
which join you intend to use. For convenience, you can also give an
alias for each column. For example, if we had a shop of products,
and we wanted to get the supplier and the purchaser at the same time
(both in the users) table:
js: |
```js
@@ -797,7 +797,7 @@ pages:
```
- name: Filtering with inner joins
description: |
If you want to filter a table based on a child table's values you can use the `!inner()` function. For example, if you wanted
If you want to filter a table based on a child table's values you can use the `!inner()` function. For example, if you wanted
to select all rows in a `message` table which belong to a user with the `username` "Jane":
js: |
```js
@@ -818,10 +818,10 @@ pages:
```
- name: Querying JSON data
description: |
If you have data inside of a JSONB column, you can apply select
and query filters to the data values. Postgres offers a
[number of operators](https://www.postgresql.org/docs/current/functions-json.html)
for querying JSON data. Also see
If you have data inside of a JSONB column, you can apply select
and query filters to the data values. Postgres offers a
[number of operators](https://www.postgresql.org/docs/current/functions-json.html)
for querying JSON data. Also see
[PostgREST docs](http://postgrest.org/en/v7.0.0/api.html#json-columns) for more details.
js: |
```js
@@ -875,7 +875,7 @@ pages:
$ref: '@supabase/postgrest-js."lib/PostgrestQueryBuilder".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.
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
@@ -890,7 +890,7 @@ pages:
```
- 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
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
@@ -903,10 +903,10 @@ pages:
```
- name: Upsert
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 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.
js: |
```js
@@ -938,16 +938,16 @@ pages:
```
- name: Updating JSON data
description: |
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,
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.
js: |
```js
const { data, error } = await supabase
.from('users')
.update(`
address: {
address: {
street: 'Melrose Place',
postcode: 90210
}
@@ -959,7 +959,7 @@ pages:
title: 'Upsert data: upsert()'
$ref: '@supabase/postgrest-js."lib/PostgrestQueryBuilder".PostgrestQueryBuilder.upsert'
notes: |
- Primary keys should be included in the data payload in order for an update to work correctly.
- Primary keys should 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
@@ -983,8 +983,8 @@ pages:
```
- name: Upserting into tables with constraints
description: |
Running the following will cause supabase to upsert data into the `users` table.
If the username 'supabot' already exists, the `onConflict` argument tells supabase to overwrite that row
Running the following will cause supabase to upsert data into the `users` table.
If the username 'supabot' already exists, the `onConflict` argument tells supabase to overwrite that row
based on the column passed into `onConflict`.
isSpotlight: true
js: |
@@ -999,11 +999,11 @@ pages:
```js
const { data, error, count } = await supabase
.from('users')
.upsert({
id: 3, message: 'foo',
username: 'supabot'
}, {
count: 'exact'
.upsert({
id: 3, message: 'foo',
username: 'supabot'
}, {
count: 'exact'
})
```
@@ -1067,7 +1067,7 @@ pages:
- name: With filters
description: |
Postgres functions that return tables can also be combined with
[Modifiers](/docs/reference/javascript/using-modifiers) and
[Modifiers](/docs/reference/javascript/using-modifiers) and
[Filters](/docs/reference/javascript/using-filters).
js: |
```js
@@ -1126,8 +1126,8 @@ pages:
```
- name: Listening to updates
description: |
By default, Supabase will send only the updated record. If you want to receive the previous values as well you can
enable full replication for the table you are listening too:
By default, Supabase will send only the updated record. If you want to receive the previous values as well you can
enable full replication for the table you are listening too:
```sql
alter table "your_table" replica identity full;
@@ -1143,8 +1143,8 @@ pages:
```
- name: Listening to deletes
description: |
By default, Supabase does not send deleted records. If you want to receive the deleted record you can
enable full replication for the table you are listening too:
By default, Supabase does not send deleted records. If you want to receive the deleted record you can
enable full replication for the table you are listening too:
```sql
alter table "your_table" replica identity full;
@@ -1222,7 +1222,7 @@ pages:
$ref: '@supabase/storage-js."lib/StorageBucketApi".StorageBucketApi.listBuckets'
notes: |
- Policy permissions required:
- `buckets` permissions: `select`
- `buckets` permissions: `select`
- `objects` permissions: none
examples:
- name: List buckets
@@ -1239,7 +1239,7 @@ pages:
$ref: '@supabase/storage-js."lib/StorageBucketApi".StorageBucketApi.getBucket'
notes: |
- Policy permissions required:
- `buckets` permissions: `select`
- `buckets` permissions: `select`
- `objects` permissions: none
examples:
- name: Get bucket
@@ -1256,7 +1256,7 @@ pages:
$ref: '@supabase/storage-js."lib/StorageBucketApi".StorageBucketApi.createBucket'
notes: |
- Policy permissions required:
- `buckets` permissions: `insert`
- `buckets` permissions: `insert`
- `objects` permissions: none
examples:
- name: Create bucket
@@ -1273,7 +1273,7 @@ pages:
$ref: '@supabase/storage-js."lib/StorageBucketApi".StorageBucketApi.emptyBucket'
notes: |
- Policy permissions required:
- `buckets` permissions: `select`
- `buckets` permissions: `select`
- `objects` permissions: `select` and `delete`
examples:
- name: Empty bucket
@@ -1323,7 +1323,7 @@ pages:
$ref: '@supabase/storage-js."lib/StorageFileApi".StorageFileApi.upload'
notes: |
- Policy permissions required:
- `buckets` permissions: none
- `buckets` permissions: none
- `objects` permissions: `insert`
- For React Native, using either `Blob`, `File` or `FormData` does not work as intended. Upload file using `ArrayBuffer` from base64 file data instead, see example below.
examples:
@@ -1358,7 +1358,7 @@ pages:
$ref: '@supabase/storage-js."lib/StorageFileApi".StorageFileApi.update'
notes: |
- Policy permissions required:
- `buckets` permissions: none
- `buckets` permissions: none
- `objects` permissions: `update` and `select`
- For React Native, using either `Blob`, `File` or `FormData` does not work as intended. Update file using `ArrayBuffer` from base64 file data instead, see example below.
examples:
@@ -1393,7 +1393,7 @@ pages:
$ref: '@supabase/storage-js."lib/StorageFileApi".StorageFileApi.move'
notes: |
- Policy permissions required:
- `buckets` permissions: none
- `buckets` permissions: none
- `objects` permissions: `update` and `select`
examples:
- name: Move file
@@ -1411,8 +1411,8 @@ pages:
$ref: '@supabase/storage-js."lib/StorageFileApi".StorageFileApi.copy'
notes: |
- Policy permissions required:
- `buckets` permissions: none
- `objects` permissions: `update` and `select`
- `buckets` permissions: none
- `objects` permissions: `insert` and `select`
examples:
- name: Copy file
isSpotlight: true
@@ -1429,7 +1429,7 @@ pages:
$ref: '@supabase/storage-js."lib/StorageFileApi".StorageFileApi.createSignedUrl'
notes: |
- Policy permissions required:
- `buckets` permissions: none
- `buckets` permissions: none
- `objects` permissions: `select`
examples:
- name: Create Signed URL
@@ -1447,7 +1447,7 @@ pages:
$ref: '@supabase/storage-js."lib/StorageFileApi".StorageFileApi.createSignedUrls'
notes: |
- Policy permissions required:
- `buckets` permissions: none
- `buckets` permissions: none
- `objects` permissions: `select`
examples:
- name: Create Signed URLs
@@ -1466,7 +1466,7 @@ pages:
notes: |
- The bucket needs to be set to public, either via [updateBucket()](/docs/reference/javascript/storage-updatebucket) or by going to Storage on [app.supabase.com](https://app.supabase.com), clicking the overflow menu on a bucket and choosing "Make public"
- Policy permissions required:
- `buckets` permissions: none
- `buckets` permissions: none
- `objects` permissions: none
examples:
- name: Returns the URL for an asset in a public bucket
@@ -1484,7 +1484,7 @@ pages:
$ref: '@supabase/storage-js."lib/StorageFileApi".StorageFileApi.download'
notes: |
- Policy permissions required:
- `buckets` permissions: none
- `buckets` permissions: none
- `objects` permissions: `select`
examples:
- name: Download file
@@ -1502,7 +1502,7 @@ pages:
$ref: '@supabase/storage-js."lib/StorageFileApi".StorageFileApi.remove'
notes: |
- Policy permissions required:
- `buckets` permissions: none
- `buckets` permissions: none
- `objects` permissions: `delete` and `select`
examples:
- name: Delete file
@@ -1520,7 +1520,7 @@ pages:
$ref: '@supabase/storage-js."lib/StorageFileApi".StorageFileApi.list'
notes: |
- Policy permissions required:
- `buckets` permissions: none
- `buckets` permissions: none
- `objects` permissions: `select`
examples:
- name: List files in a bucket
@@ -1552,7 +1552,7 @@ pages:
Using Modifiers:
description: |
Modifiers can be used on `select()` queries.
Modifiers can be used on `select()` queries.
If a Postgres function returns a table response, you can also apply modifiers to the `rpc()` function.
@@ -1651,7 +1651,7 @@ pages:
Using Filters:
description: |
Filters can be used on `select()`, `update()`, and `delete()` queries.
Filters can be used on `select()`, `update()`, and `delete()` queries.
If a Postgres function returns a table response, you can also apply filters.
@@ -1695,7 +1695,7 @@ pages:
let query = supabase
.from('cities')
.select('name, country_id')
if (filterByName) { query = query.eq('name', filterByName) }
if (filterPopLow) { query = query.gte('population', filterPopLow) }
if (filterPopHigh) { query = query.lt('population', filterPopHigh) }
@@ -2529,8 +2529,8 @@ pages:
const { data, error } = await supabase
.from('quotes')
.select('catchphrase')
.textSearch('catchphrase', `'fat' & 'cat'`, {
config: 'english'
.textSearch('catchphrase', `'fat' & 'cat'`, {
config: 'english'
})
```
- name: Basic normalization
@@ -2540,9 +2540,9 @@ pages:
const { data, error } = await supabase
.from('quotes')
.select('catchphrase')
.textSearch('catchphrase', `'fat' & 'cat'`, {
.textSearch('catchphrase', `'fat' & 'cat'`, {
type: 'plain',
config: 'english'
config: 'english'
})
```
- name: Full normalization
@@ -2552,15 +2552,15 @@ pages:
const { data, error } = await supabase
.from('quotes')
.select('catchphrase')
.textSearch('catchphrase', `'fat' & 'cat'`, {
.textSearch('catchphrase', `'fat' & 'cat'`, {
type: 'phrase',
config: 'english'
config: 'english'
})
```
- name: Websearch
description: |
Uses PostgreSQL's `websearch_to_tsquery` function.
This function will never raise syntax errors, which makes it possible to use raw user-supplied input for search, and can be used
Uses PostgreSQL's `websearch_to_tsquery` function.
This function will never raise syntax errors, which makes it possible to use raw user-supplied input for search, and can be used
with advanced operators.
- `unquoted text`: text not inside quote marks will be converted to terms separated by & operators, as if processed by plainto_tsquery.
@@ -2573,7 +2573,7 @@ pages:
const { data, error } = await supabase
.from('quotes')
.select('catchphrase')
.textSearch('catchphrase', `'fat or cat'`, {
.textSearch('catchphrase', `'fat or cat'`, {
type: 'websearch',
config: 'english'
})
+1 -1
View File
@@ -1314,7 +1314,7 @@ pages:
notes: |
- Policy permissions required:
- `buckets` permissions: none
- `objects` permissions: `update` and `select`
- `objects` permissions: `insert` and `select`
examples:
- name: Copy file
isSpotlight: true