mirror of
https://github.com/supabase/supabase.git
synced 2026-10-08 02:45:07 +03:00
12 files changed
+56
-56
No files matched your search
@@ -8,7 +8,7 @@ import Tabs from '@theme/Tabs'
|
||||
import TabItem from '@theme/TabItem'
|
||||
|
||||
Postgres has built-in support for [SQL functions](https://www.postgresql.org/docs/current/sql-createfunction.html).
|
||||
These functions live inside your database, and they can be [used with the API](/docs/reference/javascript/rpc).
|
||||
These functions live inside your database, and they can be [used with the API](../../reference/javascript/rpc).
|
||||
|
||||
## Quick demo
|
||||
|
||||
@@ -25,7 +25,7 @@ These functions live inside your database, and they can be [used with the API](/
|
||||
## Getting started
|
||||
|
||||
Supabase provides several options for creating database functions. You can use the Dashboard or create them directly using SQL.
|
||||
We provide a SQL editor within the Dashboard, or you can [connect](/docs/guides/database/connecting/connecting-to-postgres) to your database
|
||||
We provide a SQL editor within the Dashboard, or you can [connect](../../guides/database/connecting-to-postgres) to your database
|
||||
and run the SQL queries yourself.
|
||||
|
||||
1. Go to the "SQL editor" section.
|
||||
@@ -49,7 +49,7 @@ $$; --6
|
||||
|
||||
<details>
|
||||
<summary>Show/Hide Details</summary>
|
||||
|
||||
|
||||
At it's most basic a function has the following parts:
|
||||
|
||||
1. `create or replace function hello_world()`: The function declaration, where `hello_world` is the name of the function. You can use either `create` when creating a new function or `replace` when replacing an existing function. Or you can use `create or replace` together to handle either.
|
||||
@@ -86,7 +86,7 @@ select hello_world();
|
||||
const { data, error } = await supabase.rpc('hello_world')
|
||||
```
|
||||
|
||||
Reference: [rpc()](/docs/reference/javascript/rpc)
|
||||
Reference: [rpc()](../../reference/javascript/rpc)
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="Dart">
|
||||
@@ -97,7 +97,7 @@ final res = await supabase
|
||||
.execute();
|
||||
```
|
||||
|
||||
Reference: [rpc()](/docs/reference/dart/rpc)
|
||||
Reference: [rpc()](../../reference/dart/rpc)
|
||||
|
||||
</TabItem>
|
||||
|
||||
@@ -105,7 +105,7 @@ Reference: [rpc()](/docs/reference/dart/rpc)
|
||||
|
||||
## Returning data sets
|
||||
|
||||
Database Functions can also return data sets from [Tables](/docs/guides/database/tables) or Views.
|
||||
Database Functions can also return data sets from [Tables](../../guides/database/tables) or Views.
|
||||
|
||||
For example, if we had a database with some Star Wars data inside:
|
||||
|
||||
@@ -279,10 +279,10 @@ final res = await supabase
|
||||
|
||||
### Database Functions vs Edge Functions
|
||||
|
||||
For data-intensive operations we recommend using [Database Functions](/docs/guides/database/functions), which are executed within your database
|
||||
and can be called remotely using the [REST and GraphQL API](/docs/guides/database/api).
|
||||
For data-intensive operations we recommend using [Database Functions](../../guides/database/functions), which are executed within your database
|
||||
and can be called remotely using the [REST and GraphQL API](../../guides/database/api).
|
||||
|
||||
For use-cases which require low-latency we recommend [Edge Functions](/docs/guides/functions), which are globally-distributed and can be written in Typescript.
|
||||
For use-cases which require low-latency we recommend [Edge Functions](../../guides/functions), which are globally-distributed and can be written in Typescript.
|
||||
|
||||
### Security `definer` vs `invoker`
|
||||
|
||||
@@ -305,7 +305,7 @@ This limits the potential damage if you allow access to schemas which the user e
|
||||
|
||||
## Resources
|
||||
|
||||
- Official Client libraries: [JavaScript](/docs/reference/javascript/rpc) and [Dart](/docs/reference/dart/rpc)
|
||||
- Official Client libraries: [JavaScript](../../reference/javascript/rpc) and [Dart](../../reference/dart/rpc)
|
||||
- Community client libraries: [github.com/supabase-community](https://github.com/supabase-community)
|
||||
- PostgreSQL Official Docs: [Chapter 9. Functions and Operators](https://www.postgresql.org/docs/current/functions.html)
|
||||
- PostgreSQL Reference: [CREATE FUNCTION](https://www.postgresql.org/docs/9.1/sql-createfunction.html)
|
||||
|
||||
@@ -30,7 +30,7 @@ When creating a table, it's best practice to add columns at the same time.
|
||||
You must define the "data type" of each column when it is created. You can add and remove columns at any time after creating a table.
|
||||
|
||||
Supabase provides several options for creating tables. You can use the Dashboard or create them directly using SQL.
|
||||
We provide a SQL editor within the Dashboard, or you can [connect](/docs/guides/database/connecting/connecting-to-postgres) to your database
|
||||
We provide a SQL editor within the Dashboard, or you can [connect](../../guides/database/connecting-to-postgres) to your database
|
||||
and run the SQL queries yourself.
|
||||
|
||||
<Tabs
|
||||
@@ -172,7 +172,7 @@ create table movies (
|
||||
|
||||
## Loading data
|
||||
|
||||
There are several ways to load data in Supabase. You can load data directly into the database or using the [APIs](/docs/guides/api).
|
||||
There are several ways to load data in Supabase. You can load data directly into the database or using the [APIs](../../guides/api).
|
||||
Use the "Bulk Loading" instructions if you are loading large data sets.
|
||||
|
||||
### Basic data loading
|
||||
@@ -242,7 +242,7 @@ For example, if you wanted to load a CSV file into your movies table:
|
||||
"Return of the Jedi", "After a daring mission to rescue Han Solo from Jabba the Hutt, the Rebels dispatch to Endor to destroy the second Death Star."
|
||||
```
|
||||
|
||||
You would [connect](/docs/guides/database/connecting-to-postgres#direct-connections) to your database directly and load the file with the COPY command:
|
||||
You would [connect](../../guides/database/connecting-to-postgres#direct-connections) to your database directly and load the file with the COPY command:
|
||||
|
||||
```bash
|
||||
psql -h DATABASE_URL -p 5432 postgres -U postgres \
|
||||
|
||||
@@ -40,11 +40,11 @@ Now visit [http://localhost:3000](http://localhost:3000) to start using Supabase
|
||||
|
||||
While we provided you with some example secrets for getting started, you should NEVER deploy your Supabase setup using the defaults we have provided.
|
||||
|
||||
Please follow these steps to secure your Docker setup. We [strongly recommend](/docs/guides/hosting/overview#managing-your-secrets) using a secrets manager when deploying to production.
|
||||
Please follow these steps to secure your Docker setup. We [strongly recommend](../../guides/hosting/overview#managing-your-secrets) using a secrets manager when deploying to production.
|
||||
|
||||
### Generate API Keys
|
||||
|
||||
Use your `JWT_SECRET` to generate a `anon` and `service` API keys using the [JWT generator](/docs/guides/hosting/overview#api-keys).
|
||||
Use your `JWT_SECRET` to generate a `anon` and `service` API keys using the [JWT generator](../../guides/hosting/overview#api-keys).
|
||||
|
||||
Replace the values in these files:
|
||||
|
||||
@@ -70,7 +70,7 @@ The Docker setup doesn't include a management database for managing users and lo
|
||||
|
||||
## Configuration
|
||||
|
||||
Each system can be [configured](/docs/guides/hosting/overview#configuration) to suit your particular use-case.
|
||||
Each system can be [configured](../../guides/hosting/overview#configuration) to suit your particular use-case.
|
||||
|
||||
To keep the setup simple, we made some choices that may not be optimal for production:
|
||||
|
||||
@@ -80,7 +80,7 @@ To keep the setup simple, we made some choices that may not be optimal for produ
|
||||
|
||||
### Using an external database
|
||||
|
||||
We strongly [recommend](/docs/guides/hosting/overview#managing-your-database) that you decouple your database from `docker-compose` before deploying.
|
||||
We strongly [recommend](../../guides/hosting/overview#managing-your-database) that you decouple your database from `docker-compose` before deploying.
|
||||
The middleware will run with any PostgreSQL database that has logical replication enabled. The following environment variables should be updated
|
||||
in the `.env` file to point to your external database:
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import JwtGenerator from '@site/src/components/JwtGenerator'
|
||||
There are several ways to use Supabase:
|
||||
|
||||
- [Supabase Cloud](https://app.supabase.com): you don't need to deploy anything. We will manage and scale your infrastructure.
|
||||
- [Docker](/docs/guides/hosting/docker): deploy to your own infrastructure.
|
||||
- [Docker](../../guides/hosting/docker): deploy to your own infrastructure.
|
||||
- Kubernetes: coming soon.
|
||||
|
||||
## Architecture
|
||||
@@ -145,7 +145,7 @@ We realize that database migrations are difficult, and this is one of the proble
|
||||
|
||||
While Supabase officially supports Docker, we have several other deployment strategies managed by the community:
|
||||
|
||||
- [supabase-docker](/docs/guides/hosting/docker) (Official)
|
||||
- [supabase-docker](../../guides/hosting/docker) (Official)
|
||||
- [supabase-kubernetes](https://github.com/supabase-community/supabase-kubernetes) (Unofficial)
|
||||
- [supabase-terraform](https://github.com/supabase-community/supabase-terraform) (Unofficial)
|
||||
- [supabase-traefik](https://github.com/supabase-community/supabase-traefik) (Unofficial)
|
||||
@@ -31,10 +31,10 @@ You can invite your Team members into your Organizations so that you can collabo
|
||||
|
||||
Each project on Supabase comes with these features:
|
||||
|
||||
- A dedicated Postgres database. [Learn more](/docs/guides/database)
|
||||
- Auto-generated APIs. [Learn more](/docs/guides/api)
|
||||
- Auth and User management. [Learn more](/docs/guides/auth)
|
||||
- Storage. [Learn more](/docs/guides/storage)
|
||||
- A dedicated Postgres database. [Learn more](../../guides/database)
|
||||
- Auto-generated APIs. [Learn more](../../guides/api)
|
||||
- Auth and User management. [Learn more](../../guides/auth)
|
||||
- Storage. [Learn more](../../guides/storage)
|
||||
|
||||
## Next Steps
|
||||
|
||||
|
||||
@@ -20,13 +20,13 @@ As well as a Log Explorer, Supabase provides a logging interface specific to eac
|
||||
|
||||

|
||||
|
||||
The API Logs can be found under `Database > API Logs`. These show all network requests for the REST and GraphQL [API](/docs/guides/api).
|
||||
The API Logs can be found under `Database > API Logs`. These show all network requests for the REST and GraphQL [API](../../guides/api).
|
||||
|
||||
### Postgres Logs
|
||||
|
||||

|
||||
|
||||
The Postgres Logs can be found under `Database > Postgres Logs`. These show all queries and activity for your [Database](/docs/guides/database).
|
||||
The Postgres Logs can be found under `Database > Postgres Logs`. These show all queries and activity for your [Database](../../guides/database).
|
||||
|
||||
## Log Explorer
|
||||
|
||||
|
||||
@@ -75,4 +75,4 @@ Using the query plan analyzer to optimize your queries is a large topic, with a
|
||||
- [Postgres Wiki.](https://wiki.postgresql.org/wiki/Using_EXPLAIN)
|
||||
- [Enterprise DB.](https://www.enterprisedb.com/blog/postgresql-query-optimization-performance-tuning-with-explain-analyze)
|
||||
|
||||
You can pair the information available from `pg_stat_statements` with the detailed system metrics available [via your metrics endpoint](/docs/guides/platform/metrics) to better understand the behavior of your DB and the queries you're executing against it.
|
||||
You can pair the information available from `pg_stat_statements` with the detailed system metrics available [via your metrics endpoint](../platform/metrics) to better understand the behavior of your DB and the queries you're executing against it.
|
||||
@@ -82,9 +82,9 @@ For any support please get in touch at beta at [supabase.com](https://supabase.c
|
||||
|
||||
### Next steps
|
||||
|
||||
- Watch [Part One: JWTs](/docs/learn/auth-deep-dive/auth-deep-dive-jwts)
|
||||
- Watch [Part Two: Row Level Security](/docs/learn/auth-deep-dive/auth-row-level-security)
|
||||
- Watch [Part Three: Policies](/docs/learn/auth-deep-dive/auth-policies)
|
||||
- Watch [Part Four: GoTrue](/docs/learn/auth-deep-dive/auth-gotrue)
|
||||
<!-- - Watch [Part Five: Google Oauth](/docs/learn/auth-deep-dive/auth-google-oauth) -->
|
||||
- Watch [Part One: JWTs](../../learn/auth-deep-dive/auth-deep-dive-jwts)
|
||||
- Watch [Part Two: Row Level Security](../../learn/auth-deep-dive/auth-row-level-security)
|
||||
- Watch [Part Three: Policies](../../learn/auth-deep-dive/auth-policies)
|
||||
- Watch [Part Four: GoTrue](../../learn/auth-deep-dive/auth-gotrue)
|
||||
<!-- - Watch [Part Five: Google Oauth](../../learn/auth-deep-dive/auth-google-oauth) -->
|
||||
- Sign up for Supabase: [app.supabase.com](https://app.supabase.com)
|
||||
@@ -56,7 +56,7 @@ const { user, session, error } = await supabase.auth.signIn({
|
||||
|
||||
If you want to request a feature, or contribute to the project directly, just head to https://github.com/supabase/gotrue and open some issues/PRs, we're always open to help.
|
||||
|
||||
In the next guide we'll be looking at how to setup external OAuth providers: Watch [Part Five: Google Oauth](/docs/learn/auth-deep-dive/auth-google-oauth)
|
||||
In the next guide we'll be looking at how to setup external OAuth providers: Watch [Part Five: Google Oauth](../../learn/auth-deep-dive/auth-google-oauth)
|
||||
|
||||
### Resources
|
||||
|
||||
@@ -64,9 +64,9 @@ In the next guide we'll be looking at how to setup external OAuth providers: Wat
|
||||
|
||||
### Next steps
|
||||
|
||||
- Watch [Part One: JWTs](/docs/learn/auth-deep-dive/auth-deep-dive-jwts)
|
||||
- Watch [Part Two: Row Level Security](/docs/learn/auth-deep-dive/auth-row-level-security)
|
||||
- Watch [Part Three: Policies](/docs/learn/auth-deep-dive/auth-policies)
|
||||
<!-- - Watch [Part Four: GoTrue](/docs/learn/auth-deep-dive/auth-gotrue) -->
|
||||
- Watch [Part Five: Google Oauth](/docs/learn/auth-deep-dive/auth-google-oauth)
|
||||
- Watch [Part One: JWTs](../../learn/auth-deep-dive/auth-deep-dive-jwts)
|
||||
- Watch [Part Two: Row Level Security](../../learn/auth-deep-dive/auth-row-level-security)
|
||||
- Watch [Part Three: Policies](../../learn/auth-deep-dive/auth-policies)
|
||||
<!-- - Watch [Part Four: GoTrue](../../learn/auth-deep-dive/auth-gotrue) -->
|
||||
- Watch [Part Five: Google Oauth](../../learn/auth-deep-dive/auth-google-oauth)
|
||||
- Sign up for Supabase: [app.supabase.com](https://app.supabase.com)
|
||||
@@ -130,7 +130,7 @@ If we put this token into https://jwt.io, we see it decodes to:
|
||||
|
||||
This JWT is signed by a `jwt_secret` specific to the developer's Supabase token (you can find this secret alongside this encoded "anon key" on your Dashboard under Settings > API page) and is required to get past the Supabase API gateway and access the developer's project.
|
||||
|
||||
The idea with this particular key is that it's safe to put into your client, meaning it's okay if your end users see this key – but _only_ if you first enable Row Level Security, which is the topic of [Part Two](/docs/learn/auth-deep-dive/auth-row-level-security) in this series.
|
||||
The idea with this particular key is that it's safe to put into your client, meaning it's okay if your end users see this key – but _only_ if you first enable Row Level Security, which is the topic of [Part Two](../../learn/auth-deep-dive/auth-row-level-security) in this series.
|
||||
|
||||
The second key, `service role key`, should only ever be used on one of your own servers or environments, and should never be shared with end users. You might use this token to do things like make batch inserts of data.
|
||||
|
||||
@@ -167,7 +167,7 @@ You'll notice that this token is quite a bit longer, since it contains informati
|
||||
}
|
||||
```
|
||||
|
||||
Now that you understand what JWTs are and where they're used in Supabase, you can explore how to use them in combination with Row Level Security to start restricting access to certain tables, rows, and columns in your Postgres database: [Part Two: Row Level Security](/docs/learn/auth-deep-dive/auth-row-level-security)
|
||||
Now that you understand what JWTs are and where they're used in Supabase, you can explore how to use them in combination with Row Level Security to start restricting access to certain tables, rows, and columns in your Postgres database: [Part Two: Row Level Security](../../learn/auth-deep-dive/auth-row-level-security)
|
||||
|
||||
### Resources
|
||||
|
||||
@@ -175,10 +175,10 @@ Now that you understand what JWTs are and where they're used in Supabase, you ca
|
||||
|
||||
### Next steps
|
||||
|
||||
<!-- - Watch [Part One: JWTs](/docs/learn/auth-deep-dive/auth-deep-dive-jwts) -->
|
||||
<!-- - Watch [Part One: JWTs](../../learn/auth-deep-dive/auth-deep-dive-jwts) -->
|
||||
|
||||
- [Part Two: Row Level Security](/docs/learn/auth-deep-dive/auth-row-level-security)
|
||||
- [Part Three: Policies](/docs/learn/auth-deep-dive/auth-policies)
|
||||
- [Part Four: GoTrue](/docs/learn/auth-deep-dive/auth-gotrue)
|
||||
- [Part Five: Google Oauth](/docs/learn/auth-deep-dive/auth-google-oauth)
|
||||
- [Part Two: Row Level Security](../../learn/auth-deep-dive/auth-row-level-security)
|
||||
- [Part Three: Policies](../../learn/auth-deep-dive/auth-policies)
|
||||
- [Part Four: GoTrue](../../learn/auth-deep-dive/auth-gotrue)
|
||||
- [Part Five: Google Oauth](../../learn/auth-deep-dive/auth-google-oauth)
|
||||
- Sign up for Supabase: [app.supabase.com](https://app.supabase.com)
|
||||
@@ -80,7 +80,7 @@ For the curious, try heading to the SQL editor and querying:
|
||||
select * from auth.users;
|
||||
```
|
||||
|
||||
If supabase-js is loaded on your site (in this case http://localhost:3000) then it will automatically pluck the access_token out of the URL and initiate a session. You can check the [session()](/docs/reference/javascript/auth-session) method to see if there is a valid session:
|
||||
If supabase-js is loaded on your site (in this case http://localhost:3000) then it will automatically pluck the access_token out of the URL and initiate a session. You can check the [session()](../../reference/javascript/auth-session) method to see if there is a valid session:
|
||||
|
||||
```jsx
|
||||
console.log(supabase.auth.session())
|
||||
@@ -161,9 +161,9 @@ You can get as creative as you like with these policies.
|
||||
|
||||
### Next steps
|
||||
|
||||
- Watch [Part One: JWTs](/docs/learn/auth-deep-dive/auth-deep-dive-jwts)
|
||||
- Watch [Part Two: Row Level Security](/docs/learn/auth-deep-dive/auth-row-level-security)
|
||||
<!-- - Watch [Part Three: Policies](/docs/learn/auth-deep-dive/auth-policies) -->
|
||||
- Watch [Part Four: GoTrue](/docs/learn/auth-deep-dive/auth-gotrue)
|
||||
- Watch [Part Five: Google Oauth](/docs/learn/auth-deep-dive/auth-google-oauth)
|
||||
- Watch [Part One: JWTs](../../learn/auth-deep-dive/auth-deep-dive-jwts)
|
||||
- Watch [Part Two: Row Level Security](../../learn/auth-deep-dive/auth-row-level-security)
|
||||
<!-- - Watch [Part Three: Policies](../../learn/auth-deep-dive/auth-policies) -->
|
||||
- Watch [Part Four: GoTrue](../../learn/auth-deep-dive/auth-gotrue)
|
||||
- Watch [Part Five: Google Oauth](../../learn/auth-deep-dive/auth-google-oauth)
|
||||
- Sign up for Supabase: [app.supabase.com](https://app.supabase.com)
|
||||
@@ -102,7 +102,7 @@ You should now be able to read from your leaderboard, but will still not be able
|
||||
|
||||
A quick reminder that you can always use your `service_role` API key to bypass these row level security policies. But be extra careful that you don't leak this key by including it in the client. This can be useful if you're building internal admin tools, or if you need to bulk insert or delete data via the API.
|
||||
|
||||
In the next guide we will look at using Policies in combination with User Accounts, so that you can restrict access to data on a User by User basis: Watch [Part Three: Policies](/docs/learn/auth-deep-dive/auth-policies)
|
||||
In the next guide we will look at using Policies in combination with User Accounts, so that you can restrict access to data on a User by User basis: Watch [Part Three: Policies](../../learn/auth-deep-dive/auth-policies)
|
||||
|
||||
### Resources
|
||||
|
||||
@@ -111,9 +111,9 @@ In the next guide we will look at using Policies in combination with User Accoun
|
||||
|
||||
### Next steps
|
||||
|
||||
- Watch [Part One: JWTs](/docs/learn/auth-deep-dive/auth-deep-dive-jwts)
|
||||
<!-- - Watch [Part Two: Row Level Security](/docs/learn/auth-deep-dive/auth-row-level-security) -->
|
||||
- Watch [Part Three: Policies](/docs/learn/auth-deep-dive/auth-policies)
|
||||
- Watch [Part Four: GoTrue](/docs/learn/auth-deep-dive/auth-gotrue)
|
||||
- Watch [Part Five: Google Oauth](/docs/learn/auth-deep-dive/auth-google-oauth)
|
||||
- Watch [Part One: JWTs](../../learn/auth-deep-dive/auth-deep-dive-jwts)
|
||||
<!-- - Watch [Part Two: Row Level Security](../../learn/auth-deep-dive/auth-row-level-security) -->
|
||||
- Watch [Part Three: Policies](../../learn/auth-deep-dive/auth-policies)
|
||||
- Watch [Part Four: GoTrue](../../learn/auth-deep-dive/auth-gotrue)
|
||||
- Watch [Part Five: Google Oauth](../../learn/auth-deep-dive/auth-google-oauth)
|
||||
- Sign up for Supabase: [app.supabase.com](https://app.supabase.com)
|
||||
Reference in new issue
Block a user