The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
added HTTP Extension guide
Mark Burggrafc20969f8398d
diff --git a/web/docs/guides/database/extensions/http.mdx b/web/docs/guides/database/extensions/http.mdxnew file mode 100644index 00000000000..573dbe45324--- /dev/null+++ b/web/docs/guides/database/extensions/http.mdx@@ -0,0 +1,94 @@+---+id: http+title: "HTTP: HTTP Client"+description: An HTTP Client for PostgreSQL Functions.+---++import ExtensionsComponent from '../../../../src/components/Extensions'+import Tabs from '@theme/Tabs';+import TabItem from '@theme/TabItem';++`HTTP` is a HTTP Client extension for PostgreSQL. It can be used to make calls to HTTP REST API endpoints from inside your PostgreSQL functions.++## Overview++The `HTTP` extension allows you to make HTTP calls from inside your PostgreSQL functions, returning data back from API endpoints.+A successful call to a web URL from the `HTTP` extension returns a record with the following fields: `status`, `content_type`, `headers`, and `content`.+++++## Usage+++### Enabling `PLV8`++++<Tabs+defaultValue="UI"+values={[+ {label: 'UI', value: 'UI'},+ {label: 'SQL', value: 'SQL'},+]}>+<TabItem value="UI">++```bash+1. Go to the Database page+2. Click on "Extensions" in the sidebar+3. Find the extension you would like to enable/disable+4. Click the toggle.+```++++</TabItem>+<TabItem value="SQL">++```sql++-- Example: enable the "http" extension+create extenstion http;++-- Example: disable the "http" extension+drop extenstion http;++```++Even though the SQL code is `create extension`, this is the equivelent of "enabling the extension".+To disable an extension you can call `drop extension`.++</TabItem>++</Tabs>++### `HTTP` functions++While the main `HTTP` function is simply `http(http_request)`, there are 5 wrapper functions for specific functionality:++- `http_get()`+- `http_post()`+- `http_put()`+- `http_delete()`+- `http_head()`++### Using the `HTTP` extension++Get a bunch of information about the current time (in JSON format):++```sql+SELECT content FROM http_get('http://worldtimeapi.org/api/ip');+```++Get the current ip address of the PostgreSQL server:++```sql+SELECT content::json->>'origin' as ip FROM http_get('http://httpbin.org/ip');+```+++++## Resources++- Official [`HTTP` Github Repository](https://github.com/pramsey/pgsql-http).\ No newline at end of filediff --git a/web/docs/guides/database/extensions/plv8.mdx b/web/docs/guides/database/extensions/plv8.mdxnew file mode 100644index 00000000000..50011b8fdcf--- /dev/null+++ b/web/docs/guides/database/extensions/plv8.mdx@@ -0,0 +1,106 @@+---+id: plv8+title: "PLV8: Javascript Language"+description: Javascript language for PostgreSQL.+---++import ExtensionsComponent from '../../../../src/components/Extensions'+import Tabs from '@theme/Tabs';+import TabItem from '@theme/TabItem';++`PLV8` is a trusted Javascript language extension for PostgreSQL. It can be used for database functions, triggers, etc.++## Overview++The `PLV8` extension allows you to write PostgreSQL functions using the [V8 Jasvascript engine](https://v8.dev).+It has its own runtime environment that can be customized with a runtime startup procedure (`set plv8.start_proc`)+and execution timeout period (`set plv8.execution_timeout`). It can execute multiple types of function calls inside of PostgreSQL+including `Scalar Function Calls`, `Set-returning Function Calls`, `Trigger Function Calls`, and more.+++++## Usage+++### Enabling `PLV8`++++<Tabs+defaultValue="UI"+values={[+ {label: 'UI', value: 'UI'},+ {label: 'SQL', value: 'SQL'},+]}>+<TabItem value="UI">++```bash+1. Go to the Database page+2. Click on "Extensions" in the sidebar+3. Find the extension you would like to enable/disable+4. Click the toggle.+```++++</TabItem>+<TabItem value="SQL">++```sql++-- Example: enable the "plv8" extension+create extenstion plv8;++-- Example: disable the "plv8" extension+drop extenstion plv8;++```++Even though the SQL code is `create extension`, this is the equivelent of "enabling the extension".+To disable an extension you can call `drop extension`.++</TabItem>++</Tabs>+++### Creating a `PLV8` function++A simple Scalar Function.++```sql+CREATE OR REPLACE FUNCTION HelloWorld(name text) RETURNS TEXT AS $$+ let output = `Hello from PLV8, ${name}!`;+ output += ' The time is now ' + new Date();+ return output;+$$ LANGUAGE plv8;+```++To test it:++```sql+SELECT HelloWorld('Harold');+```++A simple Scalar Function to convert a string to proper case:++```sql+CREATE OR REPLACE FUNCTION ProperCase(str text) RETURNS TEXT AS $$+ return str.toLowerCase().replace(/^(.)|\s(.)/g,+ function($1) { return $1.toUpperCase(); });+$$ LANGUAGE plv8;+```++To test it:++```sql+SELECT ProperCase('this is my title with all the words capitalized');+```++++## Resources++- Official [`PLV8` documentation](https://plv8.github.io/).+- [PLV8 Github Repository](https://github.com/plv8/plv8).\ No newline at end of file