migrates everything from ipip's branch

This commit is contained in:
Copple
2022-04-26 14:17:19 +02:00
parent 9db54c2269
commit c0916ab423
651 changed files with 64093 additions and 204 deletions

View File

@@ -0,0 +1,97 @@
---
id: auth-api-createuser
title: "createUser()"
slug: auth-api-createuser
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Creates a new user.
This function should only be called on a server. Never expose your `service_role` key in the browser.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data: user, error } = await supabase.auth.api.createUser({
name: 'Yoda'
})
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
attributes
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>UserAttributes</code>
</span>
</h4>
<div class="method-list-item-description">
The data you want to create the user with.
</div>
</li>
</ul>
## Notes
- Requires a `service_role` key.
- This function should be called on a server. Never expose your `service_role` key in the browser.
## Examples
### Create a new user.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data: user, error } = await supabase.auth.api.createUser({
name: 'Yoda'
})
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,120 @@
---
id: auth-api-deleteuser
title: "deleteUser()"
slug: auth-api-deleteuser
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Delete a user. Requires a `service_role` key.
This function should only be called on a server. Never expose your `service_role` key in the browser.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data: user, error } = await supabase.auth.api.deleteUser(
'715ed5db-f090-4b8c-a067-640ecee36aa0',
'YOUR_SERVICE_ROLE_KEY'
)
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
uid
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The user uid you want to remove.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
jwt
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
A valid JWT. Must be a full-access API key (e.g. service_role key).
</div>
</li>
</ul>
## Notes
- Requires a `service_role` key.
- This function should be called on a server. Never expose your `service_role` key in the browser.
## Examples
### Remove a user completely.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data: user, error } = await supabase.auth.api.deleteUser(
'715ed5db-f090-4b8c-a067-640ecee36aa0',
'YOUR_SERVICE_ROLE_KEY'
)
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,189 @@
---
id: auth-api-generatelink
title: "generateLink()"
slug: auth-api-generatelink
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Generates links to be sent via email or other.
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
type
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>signup</code> | <code>magiclink</code> | <code>recovery</code> | <code>invite</code>
</span>
</h4>
<div class="method-list-item-description">
The link type ("signup" or "magiclink" or "recovery" or "invite").
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
email
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The user's email.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
options
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
data
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
password
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
redirectTo
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
</ul>
</li>
</ul>
## Notes
- Requires a `service_role` key.
- This function should only be called on a server. Never expose your `service_role` key in the browser.
## Examples
### Generate invite link.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data: user, error } = await supabase.auth.api.generateLink({
type: 'invite',
email: 'email@example.com'
})
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,96 @@
---
id: auth-api-getuser
title: "getUser()"
slug: auth-api-getuser
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Gets the user details.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { user, error } = await supabase.auth.api.getUser(
'ACCESS_TOKEN_JWT',
)
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
jwt
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
A valid, logged-in JWT.
</div>
</li>
</ul>
## Notes
- Fetches the user object from the database instead of local storage.
- Note that user() fetches the user object from local storage which might not be the most updated.
- Requires the user's access_token.
## Examples
### Fetch the user object using the access_token jwt.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { user, error } = await supabase.auth.api.getUser(
'ACCESS_TOKEN_JWT',
)
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,146 @@
---
id: auth-api-inviteuserbyemail
title: "inviteUserByEmail()"
slug: auth-api-inviteuserbyemail
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Sends an invite link to an email address.
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
email
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The email address of the user.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
options
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
data
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
redirectTo
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
</ul>
</li>
</ul>
## Notes
- Requires a `service_role` key.
- This function should only be called on a server. Never expose your `service_role` key in the browser.
## Examples
### Basic example.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data: user, error } = await supabase.auth
.api
.inviteUserByEmail('email@example.com')
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,125 @@
---
id: auth-api-resetpasswordforemail
title: "resetPasswordForEmail()"
slug: auth-api-resetpasswordforemail
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Sends a reset request to an email address.
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
email
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The email address of the user.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
options
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
redirectTo
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
</ul>
</li>
</ul>
## Notes
- Requires a `service_role` key.
- This function should only be called on a server. Never expose your `service_role` key in the browser.
## Examples
### Basic example.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data: user, error } = await supabase.auth
.api
.resetPasswordForEmail('email@example.com')
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,79 @@
---
id: auth-api-sendmobileotp
title: "sendMobileOTP()"
slug: auth-api-sendmobileotp
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Sends a mobile OTP via SMS. Will register the account if it doesn't already exist
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
phone
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The user's phone number WITH international prefix
</div>
</li>
</ul>
## Notes
- Requires a `service_role` key.
- This function should only be called on a server. Never expose your `service_role` key in the browser.
## Examples
### Basic example.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data: user, error } = await supabase.auth
.api
.sendMobileOTP('12345879')
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,93 @@
---
id: auth-onauthstatechange
title: "onAuthStateChange()"
slug: auth-onauthstatechange
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Receive a notification every time an auth event happens.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
supabase.auth.onAuthStateChange((event, session) => {
console.log(event, session)
})
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
callback
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
</ul>
## Examples
### Listen to auth changes
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
supabase.auth.onAuthStateChange((event, session) => {
console.log(event, session)
})
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,65 @@
---
id: auth-session
title: "session()"
slug: auth-session
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Returns the session data, if there is an active session.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const session = supabase.auth.session()
```
</TabsPanel>
</Tabs>
## Examples
### Get the session data
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const session = supabase.auth.session()
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,160 @@
---
id: auth-setauth
title: "setAuth()"
slug: auth-setauth
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Overrides the JWT on the current client. The JWT will then be sent in all subsequent network requests.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```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')
// 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)
// This client will now send requests as this user
const { data } = await supabase.from('your_table').select()
}
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
access_token
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
a jwt access token
</div>
</li>
</ul>
## Examples
### Basic example.
This is most useful on server-side functions where you cannot log the user in, but have access to the user's access token.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```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')
// 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)
// This client will now send requests as this user
const { data } = await supabase.from('your_table').select()
}
```
</TabsPanel>
</Tabs>
### With Express.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
/**
* Make a request from the client to your server function
*/
async function makeApiRequest() {
const token = newClient.session()?.access_token
await fetch('https://example.com/withAuth', {
method: 'GET',
withCredentials: true,
credentials: 'include',
headers: {
'Content-Type': 'application/json'
'Authorization': bearer, // Your own auth
'X-Supabase-Auth': token, // Set the Supabase user
}
})
}
/**
* Use the Auth token in your server-side function.
*/
async function apiFunction(req, res) {
const { access_token } = req.get('X-Supabase-Auth')
// 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)
// This client will now send requests as this user
const { data } = await supabase.from('your_table').select()
}
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,297 @@
---
id: auth-signin
title: "signIn()"
slug: auth-signin
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Log in an existing user, or login via a third-party provider.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { user, session, error } = await supabase.auth.signIn({
email: 'example@email.com',
password: 'example-password',
})
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
__namedParameters
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>UserCredentials</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
options
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
redirectTo
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
scopes
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
</ul>
</li>
</ul>
## Notes
- A user can sign up either via email or OAuth.
- If you provide `email` without a `password`, the user will be sent a magic link.
- The magic link's destination URL is determined by the SITE_URL config variable. To change this, you can go to Authentication -> Settings on [app.supabase.io](https://app.supabase.io)
- Specifying a `provider` will open the browser to the relevant login page.
## Examples
### Sign in with email.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { user, session, error } = await supabase.auth.signIn({
email: 'example@email.com',
password: 'example-password',
})
```
</TabsPanel>
</Tabs>
### Sign in with magic link.
If no password is provided, the user will be sent a "magic link" to their email address, which they can click to open your application with a valid session. By default, a given user can only request a Magic Link once every 60 seconds.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { user, session, error } = await supabase.auth.signIn({
email: 'example@email.com'
})
```
</TabsPanel>
</Tabs>
### Sign in using third-party providers.
Supabase supports OAuth logins.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { user, session, error } = await supabase.auth.signIn({
// provider can be 'github', 'google', 'gitlab', or 'bitbucket'
provider: 'github'
})
```
</TabsPanel>
</Tabs>
### Sign in with redirect.
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 base domain must be the same as the domain in your Auth settings).
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { user, session, error } = await supabase.auth.signIn({
provider: 'github'
}, {
redirectTo: 'https://example.com/welcome'
})
```
</TabsPanel>
</Tabs>
### Sign in with scopes.
If you need additional data from an OAuth provider, you can include a space-separated list of scopes in your request to get back an OAuth provider token.
You may also need to specify the scopes in the provider's OAuth app settings, depending on the provider.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { user, session, error } = await supabase.auth.signIn({
provider: 'github'
}, {
scopes: 'repo gist notifications'
})
const oAuthToken = session.provider_token // use to access provider API
```
</TabsPanel>
</Tabs>
### Sign in using a refresh token (e.g. in React Native).
If you are completing a sign up or login in a React Native app you can pass the refresh token obtained from the provider to obtain a session.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
// An example using Expo's `AuthSession`
const redirectUri = AuthSession.makeRedirectUri({ useProxy: false });
const provider = 'google';
AuthSession.startAsync({
authUrl: `https://MYSUPABASEAPP.supabase.co/auth/v1/authorize?provider=${provider}&redirect_to=${redirectUri}`,
returnUrl: redirectUri,
}).then(async (response: any) => {
if (!response) return;
const { user, session, error } = await supabase.auth.signIn({
refreshToken: response.params?.refresh_token,
});
});
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,68 @@
---
id: auth-signout
title: "signOut()"
slug: auth-signout
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Inside a browser context, `signOut()` will remove the logged in user from the browser session
and log them out - removing all items from localstorage and then trigger a "SIGNED_OUT" event.
For server-side management, you can disable sessions by passing a JWT through to `auth.api.signOut(JWT: string)`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { error } = await supabase.auth.signOut()
```
</TabsPanel>
</Tabs>
## Examples
### Sign out
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { error } = await supabase.auth.signOut()
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,205 @@
---
id: auth-signup
title: "signUp()"
slug: auth-signup
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Creates a new user.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { user, session, error } = await supabase.auth.signUp({
email: 'example@email.com',
password: 'example-password',
})
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
__namedParameters
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>UserCredentials</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
options
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
data
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
redirectTo
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
</ul>
</li>
</ul>
## Notes
- By default, the user will need to verify their email address before logging in. If you would like to change this, you can disable "Email Confirmations" by going to Authentication -> Settings on [app.supabase.io](https://app.supabase.io)
- If "Email Confirmations" is turned on, a `user` is returned but `session` will be null
- If "Email Confirmations" is turned off, both a `user` and a `session` will be returned
- When the user confirms their email address, they will be redirected to localhost:3000 by default. To change this, you can go to Authentication -> Settings on [app.supabase.io](https://app.supabase.io)
- If signUp() is called for an existing confirmed user:
- If "Enable email confirmations" is enabled on the "Authentication" -> "Settings" page, an obfuscated / fake user object will be returned.
- If "Enable email confirmations" is disabled, an error with a message "User already registered" will be returned.
- To check if a user already exists, refer to getUser().
## Examples
### Sign up.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { user, session, error } = await supabase.auth.signUp({
email: 'example@email.com',
password: 'example-password',
})
```
</TabsPanel>
</Tabs>
### Sign up with additional user meta data.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { user, session, error } = await supabase.auth.signUp(
{
email: 'example@email.com',
password: 'example-password',
},
{
data: {
first_name: 'John',
age: 27,
}
}
)
```
</TabsPanel>
</Tabs>
### Sign up with third-party providers.
You can sign up with OAuth providers using the [`signIn()`](/docs/reference/javascript/auth-signin#sign-in-using-third-party-providers) method.

View File

@@ -0,0 +1,137 @@
---
id: auth-update
title: "update()"
slug: auth-update
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Updates user data, if there is a logged in user.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { user, error } = await supabase.auth.update({email: 'new@email.com'})
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
attributes
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>UserAttributes</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
</ul>
## Notes
User email: Email updates will send an email to both the user's current and new email with a confirmation link by default.
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`).
Use the `update()` method if you have data which rarely changes or is specific only to the logged in user.
## Examples
### Update email for authenticated user.
Sends a "Confirm Email Change" email to the new email address.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { user, error } = await supabase.auth.update({email: 'new@email.com'})
```
</TabsPanel>
</Tabs>
### Update password for authenticated user.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { user, error } = await supabase.auth.update({password: 'new password'})
```
</TabsPanel>
</Tabs>
### Update a user's metadata.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { user, error } = await supabase.auth.update({
data: { hello: 'world' }
})
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,68 @@
---
id: auth-user
title: "user()"
slug: auth-user
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Inside a browser context, `user()` will return the user data, if there is a logged in user.
For server-side management, you can get a user through `auth.api.getUserByCookie()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const user = supabase.auth.user()
```
</TabsPanel>
</Tabs>
## Notes
This method gets the user object from memory.
## Examples
### Get the logged in user
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const user = supabase.auth.user()
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,140 @@
---
id: containedby
title: ".containedBy()"
slug: containedby
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.select('name, id, main_exports')
.containedBy('main_exports', ['cars', 'food', 'machine'])
```
</TabsPanel>
</Tabs>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.select('name, id, main_exports')
.containedBy('main_exports', ['cars', 'food', 'machine'])
```
</TabsPanel>
</Tabs>
### With `update()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.update({ name: 'Mordor' })
.containedBy('main_exports', ['orks', 'surveillance', 'evil'])
```
</TabsPanel>
</Tabs>
### With `delete()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.delete()
.containedBy('main_exports', ['cars', 'food', 'machine'])
```
</TabsPanel>
</Tabs>
### With `rpc()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
// Only valid if the Postgres function returns a table type.
const { data, error } = await supabase
.rpc('echo_all_countries')
.containedBy('main_exports', ['cars', 'food', 'machine'])
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,140 @@
---
id: contains
title: ".contains()"
slug: contains
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.select('name, id, main_exports')
.contains('main_exports', ['oil'])
```
</TabsPanel>
</Tabs>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.select('name, id, main_exports')
.contains('main_exports', ['oil'])
```
</TabsPanel>
</Tabs>
### With `update()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.update({ name: 'Mordor' })
.contains('main_exports', ['oil'])
```
</TabsPanel>
</Tabs>
### With `delete()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.delete()
.contains('main_exports', ['oil'])
```
</TabsPanel>
</Tabs>
### With `rpc()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
// Only valid if the Postgres function returns a table type.
const { data, error } = await supabase
.rpc('echo_all_countries')
.contains('main_exports', ['oil'])
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,118 @@
---
id: delete-user
title: "Delete User"
slug: delete-user
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Delete a user. Requires a `service_role` key.
This function should only be called on a server. Never expose your `service_role` key in the browser.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { user, error } = await supabase.auth.api.deleteUser(
'715ed5db-f090-4b8c-a067-640ecee36aa0',
'YOUR_SERVICE_ROLE_KEY'
)
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
uid
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The user uid you want to remove.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
jwt
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
A valid JWT. Must be a full-access API key (e.g. service_role key).
</div>
</li>
</ul>
## Examples
### Remove a user completely.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { user, error } = await supabase.auth.api.deleteUser(
'715ed5db-f090-4b8c-a067-640ecee36aa0',
'YOUR_SERVICE_ROLE_KEY'
)
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,147 @@
---
id: delete
title: "Delete data: delete()"
slug: delete
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Performs a DELETE on the table.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.delete()
.match({ id: 666 })
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
__namedParameters
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
returning
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>minimal</code> | <code>representation</code>
</span>
</h4>
<div class="method-list-item-description">
If `true`, return the deleted row(s) in the response.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
count
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>null</code> | <code>exact</code> | <code>planned</code> | <code>estimated</code>
</span>
</h4>
<div class="method-list-item-description">
Count algorithm to use to count rows in a table.
</div>
</li>
</ul>
</li>
</ul>
## Notes
- `delete()` should always be combined with [filters](/docs/reference/javascript/using-filters) to target the item(s) you wish to delete.
- If you use `delete()` with filters and you have
[RLS](/docs/learn/auth-deep-dive/auth-row-level-security) enabled, only
rows visible through `SELECT` policies are deleted. Note that by default
no rows are visible, so you need at least one `SELECT`/`ALL` policy that
makes the rows visible.
## Examples
### Delete records
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.delete()
.match({ id: 666 })
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,186 @@
---
id: eq
title: ".eq()"
slug: eq
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Finds all rows whose value on the stated `column` exactly matches the
specified `value`.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.eq('name', 'The shire')
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
column
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
The column to filter on.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
value
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
The value to filter with.
</div>
</li>
</ul>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.eq('name', 'The shire')
```
</TabsPanel>
</Tabs>
### With `update()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.update({ name: 'Mordor' })
.eq('name', 'San Francisco')
```
</TabsPanel>
</Tabs>
### With `delete()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.delete()
.eq('name', 'Mordor')
```
</TabsPanel>
</Tabs>
### With `rpc()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
// Only valid if the Postgres function returns a table type.
const { data, error } = await supabase
.rpc('echo_all_cities')
.eq('name', 'San Francisco')
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,230 @@
---
id: filter
title: ".filter()"
slug: filter
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Finds all rows whose `column` satisfies the filter.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.filter('name', 'in', '("Paris","Tokyo")')
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
column
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
The column to filter on.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
operator
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>FilterOperator</code>
</span>
</h4>
<div class="method-list-item-description">
The operator to filter with.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
value
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>any</code>
</span>
</h4>
<div class="method-list-item-description">
The value to filter with.
</div>
</li>
</ul>
## Notes
- `.filter()` expects you to use the raw [PostgREST syntax](https://postgrest.org/en/stable/api.html#horizontal-filtering-rows) for the filter values, so it should only be used as an escape hatch in case other filters don't work.
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.filter('name', 'in', '("Paris","Tokyo")')
```
</TabsPanel>
</Tabs>
### With `update()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.update({ name: 'Mordor' })
.filter('name', 'in', '("Paris","Tokyo")')
```
</TabsPanel>
</Tabs>
### With `delete()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.delete()
.filter('name', 'in', '("Paris","Tokyo")')
```
</TabsPanel>
</Tabs>
### With `rpc()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
// Only valid if the Postgres function returns a table type.
const { data, error } = await supabase
.rpc('echo_all_cities')
.filter('name', 'in', '("Paris","Tokyo")')
```
</TabsPanel>
</Tabs>
### Filter embedded resources
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, countries ( name )')
.filter('countries.name', 'in', '("France","Japan")')
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,136 @@
---
id: generating-types
title: "Generating Types"
slug: generating-types
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Supabase will soon release native type generators that dump your database types for various languages. For now, we support TypeScript through a third-party tool.
## Usage with TypeScript
`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.
If you don't provide a type for the row you need to explicitly pass `from<any>('tableName')`.
```ts
type Message = {
id: number;
inserted_at: string;
message: string;
user_id: string;
channel_id: number;
author: { username: string };
}
const response = await supabase
.from<Message>('messages') // Message maps to the type of the row in your database.
.select('*, author:user_id(username)')
.match({ channel_id: 2 }) // Your IDE will be able to help with auto-completion.
response.data // Response data will be of type Array<Message>.
// If you don't provide a type for the row you need to explicitly pass `from<any>('tableName')`.
const response = await supabase
.from<any>('messages')
.select('*, author:user_id(username)')
.match({ channel_id: 2 })
response.data // Response data will be of type Array<any>.
```
### Generate database types from OpenAPI specification
Supabase generates an OpenAPI specification file for your database which can be used to generate your data types for usage with TypeScript.
The OpenAPI specification for your Supabase project can be accessed as follows:
```txt
https://your-project.supabase.co/rest/v1/?apikey=your-anon-key
```
Using the open source [openapi-typescript](https://github.com/drwpow/openapi-typescript#%EF%B8%8F-reading-specs-from-remote-resource) tool you can generate your types and store them locally:
```bash
npx openapi-typescript https://your-project.supabase.co/rest/v1/?apikey=your-anon-key --output types/supabase.ts
```
Important notes:
- Since the generator uses JSON API, there is no way to determine if a column is an Array. It will generate array types as `string`, even though Supabase handles this automatically and returns arrays.
You can fix this manually in the files by changing the type, e.g. `names: string` -> `names: string[]`
- The types won't automatically stay in sync with your database, so make sure to regenerate your types after your make changes to your database.
After you have generated your types, you can use them in your TypeScript projects:
```ts
import { NextApiRequest, NextApiResponse } from "next";
import { createClient } from "@supabase/supabase-js";
import { definitions } from "../../types/supabase";
const supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL,
process.env.SUPABASE_SECRET_KEY
);
export default async (req: NextApiRequest, res: NextApiResponse) => {
const allOnlineUsers = await supabase
.from<definitions["users"]>("users")
.select("*")
.eq("status", "ONLINE");
res.status(200).json(allOnlineUsers);
};
```
### Update types automatically with GitHub Actions
One way to keep your type definitions in sync with your database is to set up a GitHub action that runs on a schedule.
Add a script to your package.json to generate the types:
```
"update-types": "npx openapi-typescript https://your-project.supabase.co/rest/v1/?apikey=your-anon-key --output types/database/index.ts"
```
In your repo, create the file `.github/workflows/update-types.yml`. Add the following snippet into this file to define the action. If there is a change to your definitions, this script will commit the change to your repo.
```yml
name: Update database types
on:
schedule:
# sets the action to run daily. You can modify this to run the action more or less frequently
- cron: '0 0 * * *'
jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 0
- uses: actions/setup-node@v2.1.5
with:
node-version: 14
- run: npm run update-types
- name: check for file changes
id: git_status
run: |
echo "::set-output name=status::$(git status -s)"
- name: Commit files
if: ${{contains(steps.git_status.outputs.status, ' ')}}
run: |
git add types/database/index.ts
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "Update database types" -a
- name: Push changes
if: ${{contains(steps.git_status.outputs.status, ' ')}}
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
```

View File

@@ -0,0 +1,65 @@
---
id: getsubscriptions
title: "getSubscriptions()"
slug: getsubscriptions
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Returns an array of all your subscriptions.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const subscriptions = supabase.getSubscriptions()
```
</TabsPanel>
</Tabs>
## Examples
### Get all subscriptions
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const subscriptions = supabase.getSubscriptions()
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,186 @@
---
id: gt
title: ".gt()"
slug: gt
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Finds all rows whose value on the stated `column` is greater than the
specified `value`.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.gt('country_id', 250)
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
column
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
The column to filter on.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
value
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
The value to filter with.
</div>
</li>
</ul>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.gt('country_id', 250)
```
</TabsPanel>
</Tabs>
### With `update()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.update({ name: 'Mordor' })
.gt('country_id', 250)
```
</TabsPanel>
</Tabs>
### With `delete()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.delete()
.gt('country_id', 250)
```
</TabsPanel>
</Tabs>
### With `rpc()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
// Only valid if the Postgres function returns a table type.
const { data, error } = await supabase
.rpc('echo_all_cities')
.gt('country_id', 250)
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,186 @@
---
id: gte
title: ".gte()"
slug: gte
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Finds all rows whose value on the stated `column` is greater than or
equal to the specified `value`.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.gte('country_id', 250)
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
column
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
The column to filter on.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
value
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
The value to filter with.
</div>
</li>
</ul>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.gte('country_id', 250)
```
</TabsPanel>
</Tabs>
### With `update()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.update({ name: 'Mordor' })
.gte('country_id', 250)
```
</TabsPanel>
</Tabs>
### With `delete()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.delete()
.gte('country_id', 250)
```
</TabsPanel>
</Tabs>
### With `rpc()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
// Only valid if the Postgres function returns a table type.
const { data, error } = await supabase
.rpc('echo_all_cities')
.gte('country_id', 250)
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,186 @@
---
id: ilike
title: ".ilike()"
slug: ilike
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Finds all rows whose value in the stated `column` matches the supplied
`pattern` (case insensitive).
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.ilike('name', '%la%')
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
column
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
The column to filter on.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
pattern
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The pattern to filter with.
</div>
</li>
</ul>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.ilike('name', '%la%')
```
</TabsPanel>
</Tabs>
### With `update()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.update({ name: 'Mordor' })
.ilike('name', '%la%')
```
</TabsPanel>
</Tabs>
### With `delete()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.delete()
.ilike('name', '%la%')
```
</TabsPanel>
</Tabs>
### With `rpc()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
// Only valid if the Postgres function returns a table type.
const { data, error } = await supabase
.rpc('echo_all_cities')
.ilike('name', '%la%')
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,186 @@
---
id: in
title: ".in()"
slug: in
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Finds all rows whose value on the stated `column` is found on the
specified `values`.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.in('name', ['Rio de Janeiro', 'San Francisco'])
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
column
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
The column to filter on.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
values
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
The values to filter with.
</div>
</li>
</ul>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.in('name', ['Rio de Janeiro', 'San Francisco'])
```
</TabsPanel>
</Tabs>
### With `update()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.update({ name: 'Mordor' })
.in('name', ['Rio de Janeiro', 'San Francisco'])
```
</TabsPanel>
</Tabs>
### With `delete()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.delete()
.in('name', ['Rio de Janeiro', 'San Francisco'])
```
</TabsPanel>
</Tabs>
### With `rpc()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
// Only valid if the Postgres function returns a table type.
const { data, error } = await supabase
.rpc('echo_all_cities')
.in('name', ['Rio de Janeiro', 'San Francisco'])
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,211 @@
---
id: initializing
title: "Initializing"
slug: initializing
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
You can initialize a new Supabase client using the `createClient()` method.
The Supabase client is your entrypoint to the rest of the Supabase functionality
and is the easiest way to interact with everything we offer within the Supabase ecosystem.
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
supabaseUrl
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The unique Supabase URL which is supplied when you create a new project in your project dashboard.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
supabaseKey
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The unique Supabase Key which is supplied when you create a new project in your project dashboard.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
options
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>SupabaseClientOptions</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
</ul>
## Examples
### createClient()
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
import { createClient } from '@supabase/supabase-js'
// Create a single supabase client for interacting with your database
const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key')
```
</TabsPanel>
</Tabs>
### With additional parameters
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
import { createClient } from '@supabase/supabase-js'
const options = {
schema: 'public',
headers: { 'x-my-custom-header': 'my-app-name' },
autoRefreshToken: true,
persistSession: true,
detectSessionInUrl: true
}
const supabase = createClient("https://xyzcompany.supabase.co", "public-anon-key", options)
```
</TabsPanel>
</Tabs>
### API schemas
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
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'
})
```
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.
</TabsPanel>
</Tabs>
### Custom `fetch` implementation
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
import { createClient } from '@supabase/supabase-js'
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.
This is most useful in environments where `cross-fetch` is not compatible (for instance Cloudflare Workers).
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,179 @@
---
id: insert
title: "Create data: insert()"
slug: insert
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Performs an INSERT into the table.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.insert([
{ name: 'The Shire', country_id: 554 }
])
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
values
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>Partial</code> | <code>array</code>
</span>
</h4>
<div class="method-list-item-description">
The values to insert.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
options
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>undefined</code> | <code>reflection</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
</ul>
## 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
### Create a record
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.insert([
{ name: 'The Shire', country_id: 554 }
])
```
</TabsPanel>
</Tabs>
### Bulk create
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.insert([
{ name: 'The Shire', country_id: 554 },
{ name: 'Rohan', country_id: 555 },
])
```
</TabsPanel>
</Tabs>
### Upsert
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.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="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 })
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,42 @@
---
id: installing
title: "Installing"
slug: installing
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
All JavaScript libraries are built directly by the Supabase team.
Other languages are built by the community and supported by Supabase.
## JavaScript
Via NPM
```bash
npm install @supabase/supabase-js
```
Via Yarn
```bash
yarn add @supabase/supabase-js
```
Find the source code on [GitHub](https://github.com/supabase/supabase-js).
Or via CDN
```js
<script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js"></script>
//or
<script src="https://unpkg.com/@supabase/supabase-js"></script>
```
## Python
```bash
pip install supabase-py
```
Find the source code on [GitHub](https://github.com/supabase/supabase-py).

View File

@@ -0,0 +1,186 @@
---
id: is
title: ".is()"
slug: is
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
A check for exact equality (null, true, false), finds all rows whose
value on the stated `column` exactly match the specified `value`.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.is('name', null)
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
column
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
The column to filter on.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
value
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>boolean</code> | <code>null</code>
</span>
</h4>
<div class="method-list-item-description">
The value to filter with.
</div>
</li>
</ul>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.is('name', null)
```
</TabsPanel>
</Tabs>
### With `update()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.update({ name: 'Mordor' })
.is('name', null)
```
</TabsPanel>
</Tabs>
### With `delete()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.delete()
.is('name', null)
```
</TabsPanel>
</Tabs>
### With `rpc()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
// Only valid if the Postgres function returns a table type.
const { data, error } = await supabase
.rpc('echo_all_cities')
.is('name', null)
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,186 @@
---
id: like
title: ".like()"
slug: like
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Finds all rows whose value in the stated `column` matches the supplied
`pattern` (case sensitive).
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.like('name', '%la%')
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
column
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
The column to filter on.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
pattern
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The pattern to filter with.
</div>
</li>
</ul>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.like('name', '%la%')
```
</TabsPanel>
</Tabs>
### With `update()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.update({ name: 'Mordor' })
.like('name', '%la%')
```
</TabsPanel>
</Tabs>
### With `delete()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.delete()
.like('name', '%la%')
```
</TabsPanel>
</Tabs>
### With `rpc()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
// Only valid if the Postgres function returns a table type.
const { data, error } = await supabase
.rpc('echo_all_cities')
.like('name', '%la%')
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,165 @@
---
id: limit
title: "limit()"
slug: limit
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Limits the result with the specified `count`.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.limit(1)
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
count
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>number</code>
</span>
</h4>
<div class="method-list-item-description">
The maximum no. of rows to limit to.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
__namedParameters
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
foreignTable
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>undefined</code> | <code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The foreign table to use (for foreign columns).
</div>
</li>
</ul>
</li>
</ul>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.limit(1)
```
</TabsPanel>
</Tabs>
### With embedded resources
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.select('name, cities(name)')
.eq('name', 'United States')
.limit(1, { foreignTable: 'cities' })
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,186 @@
---
id: lt
title: ".lt()"
slug: lt
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Finds all rows whose value on the stated `column` is less than the
specified `value`.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.lt('country_id', 250)
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
column
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
The column to filter on.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
value
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
The value to filter with.
</div>
</li>
</ul>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.lt('country_id', 250)
```
</TabsPanel>
</Tabs>
### With `update()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.update({ name: 'Mordor' })
.lt('country_id', 250)
```
</TabsPanel>
</Tabs>
### With `delete()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.delete()
.lt('country_id', 250)
```
</TabsPanel>
</Tabs>
### With `rpc()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
// Only valid if the Postgres function returns a table type.
const { data, error } = await supabase
.rpc('echo_all_cities')
.lt('country_id', 250)
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,186 @@
---
id: lte
title: ".lte()"
slug: lte
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Finds all rows whose value on the stated `column` is less than or equal
to the specified `value`.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.lte('country_id', 250)
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
column
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
The column to filter on.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
value
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
The value to filter with.
</div>
</li>
</ul>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.lte('country_id', 250)
```
</TabsPanel>
</Tabs>
### With `update()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.update({ name: 'Mordor' })
.lte('country_id', 250)
```
</TabsPanel>
</Tabs>
### With `delete()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.delete()
.lte('country_id', 250)
```
</TabsPanel>
</Tabs>
### With `rpc()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
// Only valid if the Postgres function returns a table type.
const { data, error } = await supabase
.rpc('echo_all_cities')
.lte('country_id', 250)
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,165 @@
---
id: match
title: ".match()"
slug: match
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Finds all rows whose columns match the specified `query` object.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.match({name: 'Beijing', country_id: 156})
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
query
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>Record</code>
</span>
</h4>
<div class="method-list-item-description">
The object to filter with, with column names as keys mapped
to their filter values.
</div>
</li>
</ul>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.match({name: 'Beijing', country_id: 156})
```
</TabsPanel>
</Tabs>
### With `update()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.update({ name: 'Mordor' })
.match({name: 'Beijing', country_id: 156})
```
</TabsPanel>
</Tabs>
### With `delete()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.delete()
.match({name: 'Beijing', country_id: 156})
```
</TabsPanel>
</Tabs>
### With `rpc()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
// Only valid if the Postgres function returns a table type.
const { data, error } = await supabase
.rpc('echo_all_cities')
.match({name: 'Beijing', country_id: 156})
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,75 @@
---
id: maybesingle
title: "maybeSingle()"
slug: maybesingle
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Retrieves at most one row from the result. Result must be at most one row
(e.g. using `eq` on a UNIQUE column), otherwise this will result in an
error.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.eq('name', 'Singapore')
.maybeSingle()
```
</TabsPanel>
</Tabs>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.eq('name', 'Singapore')
.maybeSingle()
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,186 @@
---
id: neq
title: ".neq()"
slug: neq
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Finds all rows whose value on the stated `column` doesn't match the
specified `value`.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.neq('name', 'The shire')
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
column
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
The column to filter on.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
value
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
The value to filter with.
</div>
</li>
</ul>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.neq('name', 'The shire')
```
</TabsPanel>
</Tabs>
### With `update()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.update({ name: 'Mordor' })
.neq('name', 'San Francisco')
```
</TabsPanel>
</Tabs>
### With `delete()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.delete()
.neq('name', 'Mordor')
```
</TabsPanel>
</Tabs>
### With `rpc()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
// Only valid if the Postgres function returns a table type.
const { data, error } = await supabase
.rpc('echo_all_cities')
.neq('name', 'Lagos')
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,206 @@
---
id: not
title: ".not()"
slug: not
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Finds all rows which doesn't satisfy the filter.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.not('name', 'eq', 'Paris')
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
column
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
The column to filter on.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
operator
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>FilterOperator</code>
</span>
</h4>
<div class="method-list-item-description">
The operator to filter with.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
value
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>any</code>
</span>
</h4>
<div class="method-list-item-description">
The value to filter with.
</div>
</li>
</ul>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.not('name', 'eq', 'Paris')
```
</TabsPanel>
</Tabs>
### With `update()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.update({ name: 'Mordor' })
.not('name', 'eq', 'Paris')
```
</TabsPanel>
</Tabs>
### With `delete()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.delete()
.not('name', 'eq', 'Paris')
```
</TabsPanel>
</Tabs>
### With `rpc()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
// Only valid if the Postgres function returns a table type.
const { data, error } = await supabase
.rpc('echo_all_cities')
.not('name', 'eq', 'Paris')
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,187 @@
---
id: or
title: ".or()"
slug: or
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Finds all rows satisfying at least one of the filters.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.or('id.eq.20,id.eq.30')
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
filters
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The filters to use, separated by commas.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
__namedParameters
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
foreignTable
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>undefined</code> | <code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The foreign table to use (if `column` is a foreign column).
</div>
</li>
</ul>
</li>
</ul>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.or('id.eq.20,id.eq.30')
```
</TabsPanel>
</Tabs>
### Use `or` with `and`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.or('id.gt.20,and(name.eq.New Zealand,name.eq.France)')
```
</TabsPanel>
</Tabs>
### Use `or` on foreign tables
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.select('id, cities(*)')
.or('name.eq.Wellington,name.eq.Paris', { foreignTable: "cities" })
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,207 @@
---
id: order
title: "order()"
slug: order
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Orders the result with the specified `column`.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name', 'country_id')
.order('id', { ascending: false })
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
column
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
The column to order on.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
__namedParameters
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
nullsFirst
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>boolean</code>
</span>
</h4>
<div class="method-list-item-description">
If `true`, `null`s appear first.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
foreignTable
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>undefined</code> | <code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The foreign table to use (if `column` is a foreign column).
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
ascending
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>boolean</code>
</span>
</h4>
<div class="method-list-item-description">
If `true`, the result will be in ascending order.
</div>
</li>
</ul>
</li>
</ul>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name', 'country_id')
.order('id', { ascending: false })
```
</TabsPanel>
</Tabs>
### With embedded resources
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.select('name, cities(name)')
.eq('name', 'United States')
.order('name', {foreignTable: 'cities'})
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,140 @@
---
id: overlaps
title: ".overlaps()"
slug: overlaps
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.select('name, id, main_exports')
.overlaps('main_exports', ['computers', 'minerals'])
```
</TabsPanel>
</Tabs>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.select('name, id, main_exports')
.overlaps('main_exports', ['computers', 'minerals'])
```
</TabsPanel>
</Tabs>
### With `update()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
let countries = await supabase
.from('countries')
.update({ name: 'Mordor' })
.overlaps('main_exports', ['computers', 'minerals'])
```
</TabsPanel>
</Tabs>
### With `delete()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.delete()
.overlaps('main_exports', ['computers', 'minerals'])
```
</TabsPanel>
</Tabs>
### With `rpc()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
// Only valid if the Postgres function returns a table type.
const { data, error } = await supabase
.rpc('echo_all_countries')
.overlaps('main_exports', ['computers', 'minerals'])
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,162 @@
---
id: range
title: "range()"
slug: range
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Limits the result to rows within the specified range, inclusive.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.range(0,3)
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
from
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>number</code>
</span>
</h4>
<div class="method-list-item-description">
The starting index from which to limit the result, inclusive.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
to
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>number</code>
</span>
</h4>
<div class="method-list-item-description">
The last index to which to limit the result, inclusive.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
__namedParameters
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
foreignTable
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>undefined</code> | <code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The foreign table to use (for foreign columns).
</div>
</li>
</ul>
</li>
</ul>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.range(0,3)
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,140 @@
---
id: rangeadjacent
title: ".rangeAdjacent()"
slug: rangeadjacent
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.select('name, id, population_range_millions')
.rangeAdjacent('population_range_millions', [70, 185])
```
</TabsPanel>
</Tabs>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.select('name, id, population_range_millions')
.rangeAdjacent('population_range_millions', [70, 185])
```
</TabsPanel>
</Tabs>
### With `update()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.update({ name: 'Mordor' })
.rangeAdjacent('population_range_millions', [70, 185])
```
</TabsPanel>
</Tabs>
### With `delete()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.delete()
.rangeAdjacent('population_range_millions', [70, 185])
```
</TabsPanel>
</Tabs>
### With `rpc()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
// Only valid if the Postgres function returns a table type.
const { data, error } = await supabase
.rpc('echo_all_countries')
.rangeAdjacent('population_range_millions', [70, 185])
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,140 @@
---
id: rangegt
title: ".rangeGt()"
slug: rangegt
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.select('name, id, population_range_millions')
.rangeGt('population_range_millions', [150, 250])
```
</TabsPanel>
</Tabs>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.select('name, id, population_range_millions')
.rangeGt('population_range_millions', [150, 250])
```
</TabsPanel>
</Tabs>
### With `update()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.update({ name: 'Mordor' })
.rangeGt('population_range_millions', [150, 250])
```
</TabsPanel>
</Tabs>
### With `delete()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.delete()
.rangeGt('population_range_millions', [150, 250])
```
</TabsPanel>
</Tabs>
### With `rpc()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
// Only valid if the Postgres function returns a table type.
const { data, error } = await supabase
.rpc('echo_all_countries')
.rangeGt('population_range_millions', [150, 250])
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,140 @@
---
id: rangegte
title: ".rangeGte()"
slug: rangegte
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.select('name, id, population_range_millions')
.rangeGte('population_range_millions', [150, 250])
```
</TabsPanel>
</Tabs>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.select('name, id, population_range_millions')
.rangeGte('population_range_millions', [150, 250])
```
</TabsPanel>
</Tabs>
### With `update()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.update({ name: 'Mordor' })
.rangeGte('population_range_millions', [150, 250])
```
</TabsPanel>
</Tabs>
### With `delete()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.delete()
.rangeGte('population_range_millions', [150, 250])
```
</TabsPanel>
</Tabs>
### With `rpc()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
// Only valid if the Postgres function returns a table type.
const { data, error } = await supabase
.rpc('echo_all_countries')
.rangeGte('population_range_millions', [150, 250])
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,140 @@
---
id: rangelt
title: ".rangeLt()"
slug: rangelt
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.select('name, id, population_range_millions')
.rangeLt('population_range_millions', [150, 250])
```
</TabsPanel>
</Tabs>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.select('name, id, population_range_millions')
.rangeLt('population_range_millions', [150, 250])
```
</TabsPanel>
</Tabs>
### With `update()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.update({ name: 'Mordor' })
.rangeLt('population_range_millions', [150, 250])
```
</TabsPanel>
</Tabs>
### With `delete()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.delete()
.rangeLt('population_range_millions', [150, 250])
```
</TabsPanel>
</Tabs>
### With `rpc()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
// Only valid if the Postgres function returns a table type.
const { data, error } = await supabase
.rpc('echo_all_countries')
.rangeLt('population_range_millions', [150, 250])
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,140 @@
---
id: rangelte
title: ".rangeLte()"
slug: rangelte
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.select('name, id, population_range_millions')
.rangeLte('population_range_millions', [150, 250])
```
</TabsPanel>
</Tabs>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.select('name, id, population_range_millions')
.rangeLte('population_range_millions', [150, 250])
```
</TabsPanel>
</Tabs>
### With `update()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.update({ name: 'Mordor' })
.rangeLte('population_range_millions', [150, 250])
```
</TabsPanel>
</Tabs>
### With `delete()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.delete()
.rangeLte('population_range_millions', [150, 250])
```
</TabsPanel>
</Tabs>
### With `rpc()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
// Only valid if the Postgres function returns a table type.
const { data, error } = await supabase
.rpc('echo_all_countries')
.rangeLte('population_range_millions', [150, 250])
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,66 @@
---
id: removeallsubscriptions
title: "removeAllSubscriptions()"
slug: removeallsubscriptions
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Removes all subscriptions and disconnects the Websocket connection.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
supabase.removeAllSubscriptions()
```
</TabsPanel>
</Tabs>
## Notes
- Removing subscriptions is a great way to maintain the performance of your project's database. Supabase will automatically handle cleanup 30 seconds after a user is disconnected, but unused subscriptions may cause degradation as more users are simultaneously subscribed.
## Examples
### Removes all subscriptions
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
supabase.removeAllSubscriptions()
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,90 @@
---
id: removesubscription
title: "removeSubscription()"
slug: removesubscription
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Removes an active subscription and returns the number of open connections.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
supabase.removeSubscription(mySubscription)
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
subscription
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>RealtimeSubscription</code>
</span>
</h4>
<div class="method-list-item-description">
The subscription you want to remove.
</div>
</li>
</ul>
## Notes
- Removing subscriptions is a great way to maintain the performance of your project's database. Supabase will automatically handle cleanup 30 seconds after a user is disconnected, but unused subscriptions may cause degradation as more users are simultaneously subscribed.
## Examples
### Remove a subscription
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
supabase.removeSubscription(mySubscription)
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,151 @@
---
id: reset-password-email
title: "Reset Password (Email)"
slug: reset-password-email
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Sends a reset request to an email address.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = supabase.auth.api
.resetPasswordForEmail('user@email.com')
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
email
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The email address of the user.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
options
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
redirectTo
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
</ul>
</li>
</ul>
## Notes
Sends a reset request to an email address.
When the user clicks the reset link in the email they will be forwarded to:
`<SITE_URL>#access_token=x&refresh_token=y&expires_in=z&token_type=bearer&type=recovery`
Your app must detect `type=recovery` in the fragment and display a password reset form to the user.
You should then use the access_token in the url and new password to update the user as follows:
```js
const { error, data } = await supabase.auth.api
.updateUser(access_token, { password : new_password })
```
## Examples
### Reset password
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = supabase.auth.api
.resetPasswordForEmail('user@email.com')
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,274 @@
---
id: rpc
title: "Postgres functions: rpc()"
slug: rpc
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
You can call Postgres functions as a "Remote Procedure Call".
That's a fancy way of saying that you can put some logic into your database then call it from anywhere.
It's especially useful when the logic rarely changes - like password resets and updates.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.rpc('hello_world')
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
fn
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The function name to call.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
params
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>undefined</code> | <code>object</code>
</span>
</h4>
<div class="method-list-item-description">
The parameters to pass to the function call.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
__namedParameters
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
head
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>boolean</code>
</span>
</h4>
<div class="method-list-item-description">
When set to true, no data will be returned.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
count
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>null</code> | <code>exact</code> | <code>planned</code> | <code>estimated</code>
</span>
</h4>
<div class="method-list-item-description">
Count algorithm to use to count rows in a table.
</div>
</li>
</ul>
</li>
</ul>
## Examples
### Call a Postgres function
This is an example of invoking a Postgres function.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.rpc('hello_world')
```
</TabsPanel>
</Tabs>
### With Parameters
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.rpc('echo_city', { name: 'The Shire' })
```
</TabsPanel>
</Tabs>
### Bulk processing
You can process large payloads at once using [array parameters](https://postgrest.org/en/stable/api.html#calling-functions-with-array-parameters).
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await postgrest
.rpc('echo_cities', { names: ['The Shire', 'Mordor'] })
```
</TabsPanel>
</Tabs>
### With filters
Postgres functions that return tables can also be combined with
[Modifiers](/docs/reference/javascript/using-modifiers) and
[Filters](/docs/reference/javascript/using-filters).
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.rpc('echo_all_cities')
.select('name, population')
.eq('name', 'The Shire')
```
</TabsPanel>
</Tabs>
### With count option
You can specify a count option to get the row count along with your data.
Allowed values for count option are `null`, `exact`, `planned` and `estimated`.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error, count } = await supabase
.rpc('hello_world', {}, { count: 'exact' })
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,388 @@
---
id: select
title: "Fetch data: select()"
slug: select
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Performs vertical filtering with SELECT.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select()
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
columns
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The columns to retrieve, separated by commas.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
__namedParameters
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
head
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>boolean</code>
</span>
</h4>
<div class="method-list-item-description">
When set to true, select will void data.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
count
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>null</code> | <code>exact</code> | <code>planned</code> | <code>estimated</code>
</span>
</h4>
<div class="method-list-item-description">
Count algorithm to use to count rows in a table.
</div>
</li>
</ul>
</li>
</ul>
## Notes
- By default, Supabase projects will return a maximum of 1,000 rows. This setting can be changed in Project API Settings. It's recommended that you keep it low to limit the payload size of accidental or malicious requests. You can use `range()` queries to paginate through your data.
- `select()` can be combined with [Modifiers](/docs/reference/javascript/using-modifiers)
- `select()` can be combined with [Filters](/docs/reference/javascript/using-filters)
## Examples
### Getting your data
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select()
```
</TabsPanel>
</Tabs>
### Selecting specific columns
You can select specific fields from your tables.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name')
```
</TabsPanel>
</Tabs>
### Query foreign tables
If your database has foreign key relationships, you can query related tables too.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.select(`
name,
cities (
name
)
`)
```
</TabsPanel>
</Tabs>
### Query the same foreign table multiple times
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:
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('products')
.select(`
id,
supplier:supplier_id ( name ),
purchaser:purchaser_id ( name )
`)
```
</TabsPanel>
</Tabs>
### Filtering with inner joins
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":
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('messages')
.select('*, users!inner(*)')
.eq('users.username', 'Jane')
```
</TabsPanel>
</Tabs>
### Querying with count option
You can get the number of rows by using the count option.
Allowed values for count option are `null`, [exact](https://postgrest.org/en/stable/api.html#exact-count), [planned](https://postgrest.org/en/stable/api.html#planned-count) and [estimated](https://postgrest.org/en/stable/api.html#estimated-count).
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error, count } = await supabase
.from('cities')
.select('name', { count: 'exact' }) // if you don't want to return any rows, you can use { count: 'exact', head: true }
```
</TabsPanel>
</Tabs>
### Querying JSON data
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.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('users')
.select(`
id, name,
address->street
`)
.eq('address->postcode', 90210)
```
</TabsPanel>
</Tabs>
### Return data as CSV
By default the data is returned in JSON format, however you can also request for it to be returned as Comma Separated Values.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('users')
.select()
.csv()
```
</TabsPanel>
</Tabs>
### Aborting requests in-flight
You can use an [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) to abort requests. Note that `status` and `statusText` doesn't mean anything for aborted requests, since the request wasn't actually fulfilled.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const ac = new AbortController()
supabase
.from('very_big_table')
.select()
.abortSignal(ac.signal)
.then(console.log)
ac.abort()
// {
// error: {
// message: 'FetchError: The user aborted a request.',
// details: '',
// hint: '',
// code: ''
// },
// data: null,
// body: null,
// count: null,
// status: 400,
// statusText: 'Bad Request'
// }
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,74 @@
---
id: single
title: "single()"
slug: single
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Retrieves only one row from the result. Result must be one row (e.g. using
`limit`), otherwise this will result in an error.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.limit(1)
.single()
```
</TabsPanel>
</Tabs>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.limit(1)
.single()
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,142 @@
---
id: storage-createbucket
title: "createBucket()"
slug: storage-createbucket
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Creates a new Storage bucket
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.storage
.createBucket('avatars', { public: false })
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
id
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
A unique identifier for the bucket you are creating.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
options
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
public
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>boolean</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
</ul>
</li>
</ul>
## Notes
- Policy permissions required:
- `buckets` permissions: `insert`
- `objects` permissions: none
## Examples
### Create bucket
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.storage
.createBucket('avatars', { public: false })
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,97 @@
---
id: storage-deletebucket
title: "deleteBucket()"
slug: storage-deletebucket
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Deletes an existing bucket. A bucket can't be deleted with existing objects inside it.
You must first `empty()` the bucket.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.storage
.deleteBucket('avatars')
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
id
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The unique identifier of the bucket you would like to delete.
</div>
</li>
</ul>
## Notes
- Policy permissions required:
- `buckets` permissions: `select` and `delete`
- `objects` permissions: none
## Examples
### Delete bucket
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.storage
.deleteBucket('avatars')
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,96 @@
---
id: storage-emptybucket
title: "emptyBucket()"
slug: storage-emptybucket
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Removes all objects inside a single bucket.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.storage
.emptyBucket('avatars')
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
id
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The unique identifier of the bucket you would like to empty.
</div>
</li>
</ul>
## Notes
- Policy permissions required:
- `buckets` permissions: `select`
- `objects` permissions: `select` and `delete`
## Examples
### Empty bucket
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.storage
.emptyBucket('avatars')
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,119 @@
---
id: storage-from-createsignedurl
title: "from.createSignedUrl()"
slug: storage-from-createsignedurl
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Create signed url to download file without requiring permissions. This URL can be valid for a set number of seconds.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { signedURL, error } = await supabase
.storage
.from('avatars')
.createSignedUrl('folder/avatar1.png', 60)
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
path
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The file path to be downloaded, including the current file name. For example `folder/image.png`.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
expiresIn
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>number</code>
</span>
</h4>
<div class="method-list-item-description">
The number of seconds until the signed URL expires. For example, `60` for a URL which is valid for one minute.
</div>
</li>
</ul>
## Notes
- Policy permissions required:
- `buckets` permissions: none
- `objects` permissions: `select`
## Examples
### Create Signed URL
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { signedURL, error } = await supabase
.storage
.from('avatars')
.createSignedUrl('folder/avatar1.png', 60)
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,98 @@
---
id: storage-from-download
title: "from.download()"
slug: storage-from-download
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Downloads a file.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.storage
.from('avatars')
.download('folder/avatar1.png')
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
path
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The file path to be downloaded, including the path and file name. For example `folder/image.png`.
</div>
</li>
</ul>
## Notes
- Policy permissions required:
- `buckets` permissions: none
- `objects` permissions: `select`
## Examples
### Download file
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.storage
.from('avatars')
.download('folder/avatar1.png')
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,99 @@
---
id: storage-from-getpublicurl
title: "from.getPublicUrl()"
slug: storage-from-getpublicurl
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Retrieve URLs for assets in public buckets
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { publicURL, error } = supabase
.storage
.from('public-bucket')
.getPublicUrl('folder/avatar1.png')
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
path
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The file path to be downloaded, including the path and file name. For example `folder/image.png`.
</div>
</li>
</ul>
## 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.io](https://app.supabase.io), clicking the overflow menu on a bucket and choosing "Make public"
- Policy permissions required:
- `buckets` permissions: none
- `objects` permissions: none
## Examples
### Returns the URL for an asset in a public bucket
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { publicURL, error } = supabase
.storage
.from('public-bucket')
.getPublicUrl('folder/avatar1.png')
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,148 @@
---
id: storage-from-list
title: "from.list()"
slug: storage-from-list
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Lists all the files within a bucket.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.storage
.from('avatars')
.list('folder', {
limit: 100,
offset: 0,
sortBy: { column: 'name', order: 'asc' },
})
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
path
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>undefined</code> | <code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The folder path.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
options
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>SearchOptions</code>
</span>
</h4>
<div class="method-list-item-description">
Search options, including `limit`, `offset`, and `sortBy`.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
parameters
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>FetchParameters</code>
</span>
</h4>
<div class="method-list-item-description">
Fetch parameters, currently only supports `signal`, which is an AbortController's signal
</div>
</li>
</ul>
## Notes
- Policy permissions required:
- `buckets` permissions: none
- `objects` permissions: `select`
## Examples
### List files in a bucket
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.storage
.from('avatars')
.list('folder', {
limit: 100,
offset: 0,
sortBy: { column: 'name', order: 'asc' },
})
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,119 @@
---
id: storage-from-move
title: "from.move()"
slug: storage-from-move
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Moves an existing file, optionally renaming it at the same time.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.storage
.from('avatars')
.move('public/avatar1.png', 'private/avatar2.png')
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
fromPath
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The original file path, including the current file name. For example `folder/image.png`.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
toPath
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The new file path, including the new file name. For example `folder/image-copy.png`.
</div>
</li>
</ul>
## Notes
- Policy permissions required:
- `buckets` permissions: none
- `objects` permissions: `update` and `select`
## Examples
### Move file
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.storage
.from('avatars')
.move('public/avatar1.png', 'private/avatar2.png')
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,98 @@
---
id: storage-from-remove
title: "from.remove()"
slug: storage-from-remove
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Deletes files within the same bucket
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.storage
.from('avatars')
.remove(['folder/avatar1.png'])
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
paths
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
An array of files to be deleted, including the path and file name. For example [`folder/image.png`].
</div>
</li>
</ul>
## Notes
- Policy permissions required:
- `buckets` permissions: none
- `objects` permissions: `delete` and `select`
## Examples
### Delete file
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.storage
.from('avatars')
.remove(['folder/avatar1.png'])
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,179 @@
---
id: storage-from-update
title: "from.update()"
slug: storage-from-update
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Replaces an existing file at the specified path with a new one.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const avatarFile = event.target.files[0]
const { data, error } = await supabase
.storage
.from('avatars')
.update('public/avatar1.png', avatarFile, {
cacheControl: '3600',
upsert: false
})
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
path
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The relative file path. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to upload.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
fileBody
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>ArrayBuffer</code> | <code>ArrayBufferView</code> | <code>Blob</code> | <code>Buffer</code> | <code>File</code> | <code>FormData</code> | <code>ReadableStream</code> | <code>ReadableStream</code> | <code>URLSearchParams</code> | <code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The body of the file to be stored in the bucket.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
fileOptions
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>FileOptions</code>
</span>
</h4>
<div class="method-list-item-description">
HTTP headers.
`cacheControl`: string, the `Cache-Control: max-age=<seconds>` seconds value.
`contentType`: string, the `Content-Type` header value. Should be specified if using a `fileBody` that is neither `Blob` nor `File` nor `FormData`, otherwise will default to `text/plain;charset=UTF-8`.
`upsert`: boolean, whether to perform an upsert.
</div>
</li>
</ul>
## Notes
- Policy permissions required:
- `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
### Update file
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const avatarFile = event.target.files[0]
const { data, error } = await supabase
.storage
.from('avatars')
.update('public/avatar1.png', avatarFile, {
cacheControl: '3600',
upsert: false
})
```
</TabsPanel>
</Tabs>
### Update file using `ArrayBuffer` from base64 file data
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
import {decode} from 'base64-arraybuffer'
const { data, error } = await supabase
.storage
.from('avatars')
.update('public/avatar1.png', decode('base64FileData'), {
contentType: 'image/png'
})
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,179 @@
---
id: storage-from-upload
title: "from.upload()"
slug: storage-from-upload
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Uploads a file to an existing bucket.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const avatarFile = event.target.files[0]
const { data, error } = await supabase
.storage
.from('avatars')
.upload('public/avatar1.png', avatarFile, {
cacheControl: '3600',
upsert: false
})
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
path
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The relative file path. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to upload.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
fileBody
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>ArrayBuffer</code> | <code>ArrayBufferView</code> | <code>Blob</code> | <code>Buffer</code> | <code>File</code> | <code>FormData</code> | <code>ReadableStream</code> | <code>ReadableStream</code> | <code>URLSearchParams</code> | <code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The body of the file to be stored in the bucket.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
fileOptions
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>FileOptions</code>
</span>
</h4>
<div class="method-list-item-description">
HTTP headers.
`cacheControl`: string, the `Cache-Control: max-age=<seconds>` seconds value.
`contentType`: string, the `Content-Type` header value. Should be specified if using a `fileBody` that is neither `Blob` nor `File` nor `FormData`, otherwise will default to `text/plain;charset=UTF-8`.
`upsert`: boolean, whether to perform an upsert.
</div>
</li>
</ul>
## Notes
- Policy permissions required:
- `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
### Upload file
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const avatarFile = event.target.files[0]
const { data, error } = await supabase
.storage
.from('avatars')
.upload('public/avatar1.png', avatarFile, {
cacheControl: '3600',
upsert: false
})
```
</TabsPanel>
</Tabs>
### Upload file using `ArrayBuffer` from base64 file data
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
import {decode} from 'base64-arraybuffer'
const { data, error } = await supabase
.storage
.from('avatars')
.upload('public/avatar1.png', decode('base64FileData'), {
contentType: 'image/png'
})
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,96 @@
---
id: storage-getbucket
title: "getBucket()"
slug: storage-getbucket
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Retrieves the details of an existing Storage bucket.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.storage
.getBucket('avatars')
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
id
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The unique identifier of the bucket you would like to retrieve.
</div>
</li>
</ul>
## Notes
- Policy permissions required:
- `buckets` permissions: `select`
- `objects` permissions: none
## Examples
### Get bucket
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.storage
.getBucket('avatars')
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,72 @@
---
id: storage-listbuckets
title: "listBuckets()"
slug: storage-listbuckets
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Retrieves the details of all Storage buckets within an existing product.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.storage
.listBuckets()
```
</TabsPanel>
</Tabs>
## Notes
- Policy permissions required:
- `buckets` permissions: `select`
- `objects` permissions: none
## Examples
### List buckets
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.storage
.listBuckets()
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,142 @@
---
id: storage-updatebucket
title: "updateBucket()"
slug: storage-updatebucket
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Updates a new Storage bucket
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.storage
.updateBucket('avatars', { public: false })
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
id
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
A unique identifier for the bucket you are creating.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
options
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
public
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>boolean</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
</ul>
</li>
</ul>
## Notes
- Policy permissions required:
- `buckets` permissions: `update`
- `objects` permissions: none
## Examples
### Update bucket
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.storage
.updateBucket('avatars', { public: false })
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,281 @@
---
id: subscribe
title: "on().subscribe()"
slug: subscribe
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Subscribe to realtime changes in your databse.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const mySubscription = supabase
.from('*')
.on('*', payload => {
console.log('Change received!', payload)
})
.subscribe()
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
event
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>SupabaseEventTypes</code>
</span>
</h4>
<div class="method-list-item-description">
The database event which you would like to receive updates for, or you can use the special wildcard `*` to listen to all changes.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
callback
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
A callback that will handle the payload that is sent whenever your database changes.
</div>
</li>
</ul>
## Notes
- Realtime is disabled by default for new Projects for better database performance and security. You can turn it on by [managing replication](/docs/guides/api#managing-realtime).
- If you want to receive the "previous" data for updates and deletes, you will need to set `REPLICA IDENTITY` to `FULL`, like this: `ALTER TABLE your_table REPLICA IDENTITY FULL;`
## Examples
### Listen to all database changes
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const mySubscription = supabase
.from('*')
.on('*', payload => {
console.log('Change received!', payload)
})
.subscribe()
```
</TabsPanel>
</Tabs>
### Listening to a specific table
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const mySubscription = supabase
.from('countries')
.on('*', payload => {
console.log('Change received!', payload)
})
.subscribe()
```
</TabsPanel>
</Tabs>
### Listening to inserts
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const mySubscription = supabase
.from('countries')
.on('INSERT', payload => {
console.log('Change received!', payload)
})
.subscribe()
```
</TabsPanel>
</Tabs>
### Listening to updates
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;
```
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const mySubscription = supabase
.from('countries')
.on('UPDATE', payload => {
console.log('Change received!', payload)
})
.subscribe()
```
</TabsPanel>
</Tabs>
### Listening to deletes
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;
```
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const mySubscription = supabase
.from('countries')
.on('DELETE', payload => {
console.log('Change received!', payload)
})
.subscribe()
```
</TabsPanel>
</Tabs>
### Listening to multiple events
You can chain listeners if you want to listen to multiple events for each table.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const mySubscription = supabase
.from('countries')
.on('INSERT', handleRecordInserted)
.on('DELETE', handleRecordDeleted)
.subscribe()
```
</TabsPanel>
</Tabs>
### Listening to row level changes
You can listen to individual rows using the format `{table}:{col}=eq.{val}` - where `{col}` is the column name, and `{val}` is the value which you want to match.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const mySubscription = supabase
.from('countries:id=eq.200')
.on('UPDATE', handleRecordUpdated)
.subscribe()
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,109 @@
---
id: index
title: "Supabase Client"
slug: supabase-client
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Our approach for client libraries is modular. Each sub-library is a standalone implementation for a single external system. This is one of the ways we support existing tools.
<table style={{tableLayout: 'fixed', whiteSpace: 'nowrap' }}>
<tr>
<th>Language</th>
<th>Client</th>
<th colspan="4">Feature-Clients (bundled in Supabase client)</th>
</tr>
<tr>
<th></th>
<th>Supabase</th>
<th><a href="https://github.com/postgrest/postgrest" target="_blank" rel="noopener noreferrer">PostgREST</a></th>
<th><a href="https://github.com/supabase/gotrue" target="_blank" rel="noopener noreferrer">GoTrue</a></th>
<th><a href="https://github.com/supabase/realtime" target="_blank" rel="noopener noreferrer">Realtime</a></th>
<th><a href="https://github.com/supabase/storage-api" target="_blank" rel="noopener noreferrer">Storage</a></th>
</tr>
<th colspan="6">⚡️ Official ⚡️</th>
<tr>
<td>JavaScript (TypeScript)</td>
<td><a href="https://github.com/supabase/supabase-js" target="_blank" rel="noopener noreferrer">supabase-js</a></td>
<td><a href="https://github.com/supabase/postgrest-js" target="_blank" rel="noopener noreferrer">postgrest-js</a></td>
<td><a href="https://github.com/supabase/gotrue-js" target="_blank" rel="noopener noreferrer">gotrue-js</a></td>
<td><a href="https://github.com/supabase/realtime-js" target="_blank" rel="noopener noreferrer">realtime-js</a></td>
<td><a href="https://github.com/supabase/storage-js" target="_blank" rel="noopener noreferrer">storage-js</a></td>
</tr>
<th colspan="6">💚 Community 💚</th>
<tr>
<td>C#</td>
<td><a href="https://github.com/supabase-community/supabase-csharp" target="_blank" rel="noopener noreferrer">supabase-csharp</a></td>
<td><a href="https://github.com/supabase-community/postgrest-csharp" target="_blank" rel="noopener noreferrer">postgrest-csharp</a></td>
<td><a href="https://github.com/supabase-community/gotrue-csharp" target="_blank" rel="noopener noreferrer">gotrue-csharp</a></td>
<td><a href="https://github.com/supabase-community/realtime-csharp" target="_blank" rel="noopener noreferrer">realtime-csharp</a></td>
<td>-</td>
</tr>
<tr>
<td>Dart (Flutter)</td>
<td><a href="https://github.com/supabase/supabase-dart" target="_blank" rel="noopener noreferrer">supabase-dart</a></td>
<td><a href="https://github.com/supabase/postgrest-dart" target="_blank" rel="noopener noreferrer">postgrest-dart</a></td>
<td><a href="https://github.com/supabase/gotrue-dart" target="_blank" rel="noopener noreferrer">gotrue-lang</a></td>
<td><a href="https://github.com/supabase/realtime-dart" target="_blank" rel="noopener noreferrer">realtime-dart</a></td>
<td><a href="https://github.com/supabase/storage-dart" target="_blank" rel="noopener noreferrer">storage-dart</a></td>
</tr>
<tr>
<td>Go</td>
<td>-</td>
<td><a href="https://github.com/supabase-community/postgrest-go" target="_blank" rel="noopener noreferrer">postgrest-go</a></td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>Java</td>
<td>-</td>
<td>-</td>
<td><a href="https://github.com/supabase-community/gotrue-java" target="_blank" rel="noopener noreferrer">gotrue-java</a></td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>Kotlin</td>
<td>-</td>
<td><a href="https://github.com/supabase-community/postgrest-kt" target="_blank" rel="noopener noreferrer">postgrest-kt</a></td>
<td><a href="https://github.com/supabase-community/gotrue-kt" target="_blank" rel="noopener noreferrer">gotrue-kt</a></td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>Python</td>
<td><a href="https://github.com/supabase-community/supabase-py" target="_blank" rel="noopener noreferrer">supabase-py</a></td>
<td><a href="https://github.com/supabase-community/postgrest-py" target="_blank" rel="noopener noreferrer">postgrest-py</a></td>
<td><a href="https://github.com/supabase-community/gotrue-py" target="_blank" rel="noopener noreferrer">gotrue-py</a></td>
<td><a href="https://github.com/supabase-community/realtime-py" target="_blank" rel="noopener noreferrer">realtime-py</a></td>
<td>-</td>
</tr>
<tr>
<td>Ruby</td>
<td><a href="https://github.com/supabase-community/supabase-rb" target="_blank" rel="noopener noreferrer">supabase-rb</a></td>
<td><a href="https://github.com/supabase-community/postgrest-rb" target="_blank" rel="noopener noreferrer">postgrest-rb</a></td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>Rust</td>
<td>-</td>
<td><a href="https://github.com/supabase-community/postgrest-rs" target="_blank" rel="noopener noreferrer">postgrest-rs</a></td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>Swift</td>
<td><a href="https://github.com/supabase-community/supabase-swift" target="_blank" rel="noopener noreferrer">supabase-swift</a></td>
<td><a href="https://github.com/supabase-community/postgrest-swift" target="_blank" rel="noopener noreferrer">postgrest-swift</a></td>
<td><a href="https://github.com/supabase-community/gotrue-swift" target="_blank" rel="noopener noreferrer">gotrue-swift</a></td>
<td><a href="https://github.com/supabase-community/realtime-swift" target="_blank" rel="noopener noreferrer">realtime-swift</a></td>
<td><a href="https://github.com/supabase-community/storage-swift" target="_blank" rel="noopener noreferrer">storage-swift</a></td>
</tr>
</table>

View File

@@ -0,0 +1,234 @@
---
id: textsearch
title: ".textSearch()"
slug: textsearch
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Finds all rows whose tsvector value on the stated `column` matches
to_tsquery(`query`).
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
column
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
The column to filter on.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
query
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The Postgres tsquery string to filter with.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
__namedParameters
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
config
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>undefined</code> | <code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The text search configuration to use.
</div>
</li>
</ul>
</li>
</ul>
## Examples
### Text search
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('quotes')
.select('catchphrase')
.textSearch('catchphrase', `'fat' & 'cat'`, {
config: 'english'
})
```
</TabsPanel>
</Tabs>
### Basic normalization
Uses PostgreSQL's `plainto_tsquery` function.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('quotes')
.select('catchphrase')
.textSearch('catchphrase', `'fat' & 'cat'`, {
type: 'plain',
config: 'english'
})
```
</TabsPanel>
</Tabs>
### Full normalization
Uses PostgreSQL's `phraseto_tsquery` function.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('quotes')
.select('catchphrase')
.textSearch('catchphrase', `'fat' & 'cat'`, {
type: 'phrase',
config: 'english'
})
```
</TabsPanel>
</Tabs>
### Full normalization
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.
- `"quoted text"`: text inside quote marks will be converted to terms separated by <-> operators, as if processed by phraseto_tsquery.
- `OR`: the word “or” will be converted to the | operator.
- `-`: a dash will be converted to the ! operator.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('quotes')
.select('catchphrase')
.textSearch('catchphrase', `'fat or cat'`, {
type: 'websearch',
config: 'english'
})
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,195 @@
---
id: update
title: "Modify data: update()"
slug: update
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Performs an UPDATE on the table.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.update({ name: 'Middle Earth' })
.match({ name: 'Auckland' })
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
values
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>Partial</code>
</span>
</h4>
<div class="method-list-item-description">
The values to update.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
__namedParameters
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
returning
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>minimal</code> | <code>representation</code>
</span>
</h4>
<div class="method-list-item-description">
By default the updated record is returned. Set this to 'minimal' if you don't need this value.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
count
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>null</code> | <code>exact</code> | <code>planned</code> | <code>estimated</code>
</span>
</h4>
<div class="method-list-item-description">
Count algorithm to use to count rows in a table.
</div>
</li>
</ul>
</li>
</ul>
## Notes
- `update()` should always be combined with [Filters](/docs/reference/javascript/using-filters) to target the item(s) you wish to update.
## Examples
### Updating your data
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.update({ name: 'Middle Earth' })
.match({ name: 'Auckland' })
```
</TabsPanel>
</Tabs>
### Updating JSON data
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.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('users')
.update(`
address: {
street: 'Melrose Place',
postcode: 90210
}
`)
.eq('address->postcode', 90210)
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,281 @@
---
id: upsert
title: "Upsert data: upsert()"
slug: upsert
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Performs an UPSERT into the table.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('messages')
.upsert({ id: 3, message: 'foo', username: 'supabot' })
```
</TabsPanel>
</Tabs>
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
values
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>Partial</code> | <code>array</code>
</span>
</h4>
<div class="method-list-item-description">
The values to insert.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
__namedParameters
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
returning
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>minimal</code> | <code>representation</code>
</span>
</h4>
<div class="method-list-item-description">
By default the new record is returned. Set this to 'minimal' if you don't need this value.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
onConflict
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>undefined</code> | <code>string</code>
</span>
</h4>
<div class="method-list-item-description">
By specifying the `on_conflict` query parameter, you can make UPSERT work on a column(s) that has a UNIQUE constraint.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
ignoreDuplicates
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>boolean</code>
</span>
</h4>
<div class="method-list-item-description">
Specifies if duplicate rows should be ignored and not inserted.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
count
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>null</code> | <code>exact</code> | <code>planned</code> | <code>estimated</code>
</span>
</h4>
<div class="method-list-item-description">
Count algorithm to use to count rows in a table.
</div>
</li>
</ul>
</li>
</ul>
## Notes
- 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
### Upsert your data
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('messages')
.upsert({ id: 3, message: 'foo', username: 'supabot' })
```
</TabsPanel>
</Tabs>
### Bulk Upsert your data
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('messages')
.upsert([
{ id: 3, message: 'foo', username: 'supabot' },
{ id: 4, message: 'bar', username: 'supabot' }
])
```
</TabsPanel>
</Tabs>
### Upserting into tables with constraints
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`.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('users')
.upsert({ username: 'supabot' }, { onConflict: 'username' })
```
</TabsPanel>
</Tabs>
### Return the exact number of rows
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error, count } = await supabase
.from('users')
.upsert({
id: 3, message: 'foo',
username: 'supabot'
}, {
count: 'exact'
})
```
</TabsPanel>
</Tabs>

View File

@@ -0,0 +1,61 @@
---
id: using-filters
title: "Using Filters"
slug: using-filters
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Filters can be used on `select()`, `update()`, and `delete()` queries.
If a Postgres function returns a table response, you can also apply filters.
### Applying Filters
You must apply your filters to the end of your query. For example:
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.eq('name', 'The Shire') // Correct
const { data, error } = await supabase
.from('cities')
.eq('name', 'The Shire') // Incorrect
.select('name, country_id')
```
### Chaining
Filters can be chained together to produce advanced queries. For example:
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.gte('population', 1000)
.lt('population', 10000)
```
### Conditional Chaining
Filters can be built up one step at a time and then executed. For example:
```js
const filterByName = null
const filterPopLow = 1000
const filterPopHigh = 10000
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) }
const { data, error } = await query
```

View File

@@ -0,0 +1,13 @@
---
id: using-modifiers
title: "Using Modifiers"
slug: using-modifiers
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Modifiers can be used on `select()` queries.
If a Postgres function returns a table response, you can also apply modifiers to the `rpc()` function.