The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
docs(database): make the guide's snippets run in document order (#50822)
Miranda Limonczenkod8b0a3e87fbb
diff --git a/apps/docs/content/guides/database/debugging-functions.mdx b/apps/docs/content/guides/database/debugging-functions.mdxindex 669f6c4e0ab..f386ae108f5 100644--- a/apps/docs/content/guides/database/debugging-functions.mdx+++ b/apps/docs/content/guides/database/debugging-functions.mdx@@ -68,14 +68,14 @@ select error_if_null(null);Value checking is common, so Postgres provides the `assert` keyword as a shorthand. It takes the following format:-```sql--- throw error when condition is false+```textassert <some condition>, 'message';```For example:```sql+-- assumes an attendance_table with an id uuid column and a student text columncreate function assert_example(name text)returns uuidlanguage plpgsql@@ -127,6 +127,7 @@ For a more complex function, or for harder debugging, log the following:- Start and end of function calls```sql+-- assumes a some_table with a col_1 int column and a col_2 text columncreate or replace function advanced_example(num int default 10)returns textlanguage plpgsqldiff --git a/apps/docs/content/guides/database/functions.mdx b/apps/docs/content/guides/database/functions.mdxindex e4d01bbc927..2cd468302db 100644--- a/apps/docs/content/guides/database/functions.mdx+++ b/apps/docs/content/guides/database/functions.mdx@@ -60,7 +60,7 @@ At its most basic, a function has the following parts:2. `returns text`: The type of data the function returns. For a function that returns nothing, write `returns void`.3. `language sql`: The language used inside the function body. This can also be a procedural language: `plpgsql`, `plpython`, etc.4. `as $$`: The function wrapper. Anything inside the `$$` symbols is part of the function body.-5. `select 'hello world';`: A basic function body. The function returns the result of the last `select` statement in its body.+5. `select 'hello world';`: A basic function body. The function returns the result of its final query, which can be an `insert`, `update`, or `delete` with a `returning` clause.6. `$$;`: The closing symbols of the function wrapper.</details>@@ -158,13 +158,13 @@ Reference: [`Rpc()`](../../reference/csharp/rpc)A database function can also return a data set from a [table](../../guides/database/tables) or a view.-For example, take a database holding some Star Wars data:+For example, create two tables holding some Star Wars data. The **Data** tab shows the rows they end up with.<Tabsscrollablesize="small"type="underlined"- defaultActiveId="data"+ defaultActiveId="sql"queryGroup="example-view"><TabPanel id="data" label="Data">@@ -200,11 +200,11 @@ create table planets ();insert into planets- (id, name)+ (name)values- (1, 'Tattoine'),- (2, 'Alderaan'),- (3, 'Kashyyyk');+ ('Tatooine'),+ ('Alderaan'),+ ('Kashyyyk');create table people (id serial primary key,@@ -213,12 +213,12 @@ create table people ();insert into people- (id, name, planet_id)+ (name, planet_id)values- (1, 'Anakin Skywalker', 1),- (2, 'Luke Skywalker', 1),- (3, 'Princess Leia', 2),- (4, 'Chewbacca', 3);+ ('Anakin Skywalker', 1),+ ('Luke Skywalker', 1),+ ('Princess Leia', 2),+ ('Chewbacca', 3);```</TabPanel>@@ -428,7 +428,7 @@ await supabase.Rpc("add_planet", new Dictionary<string, object> { { "name", "JakPostgres runs a function either as the user _calling_ it (`invoker`) or as its _creator_ (`definer`). For example:```sql-create function hello_world()+create or replace function hello_world()returns textlanguage plpgsqlsecurity definer set search_path = ''@@ -481,7 +481,7 @@ By default, any role can run a database function. You can restrict execution in- Official Client libraries: [JavaScript](../../reference/javascript/rpc) and [Flutter](../../reference/dart/rpc)- Community client libraries: [github.com/supabase-community](https://github.com/supabase-community)- Postgres Official Docs: [Chapter 9. Functions and Operators](https://www.postgresql.org/docs/current/functions.html)-- Postgres Reference: [CREATE FUNCTION](https://www.postgresql.org/docs/9.1/sql-createfunction.html)+- Postgres Reference: [CREATE FUNCTION](https://www.postgresql.org/docs/current/sql-createfunction.html)### Create a database function in the Dashboard