The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Complete Documentation for Reading Rows
Angelicof312193ea175
diff --git a/web/docs/library/restful/filters.mdx b/web/docs/library/restful/filters.mdxindex db263420a16..c09995784b4 100644--- a/web/docs/library/restful/filters.mdx+++ b/web/docs/library/restful/filters.mdx@@ -41,7 +41,7 @@ Determines whether null values will be displayed first or not. Default value wil```jssupabase.get("companies").order("employeeCount", true, true)```-The following will be returned:+The following will be returned with status code `200 OK`:```json[{ "name": "See Food App", "employeeCount": null },@@ -75,7 +75,7 @@ Index or position of the end of the specified range. If not stated, all remainin```jssupabase.get("companies").range(0,2)```-The following will be returned:+The following will be returned with status code `200 OK`:```json[{ "name": "Pied Piper", "employeeCount": 10 },@@ -89,7 +89,7 @@ The following will be returned:```jssupabase.get("companies").range(1)```-The following will be returned:+The following will be returned with status code `200 OK`:```json[{ "name": "Yao Net", "employeeCount": 100 },@@ -110,7 +110,7 @@ Returns the first row of the table as an object and **not** as an array.```jssupabase.get("companies").single()```-The following will be returned:+The following will be returned with status code `200 OK`:```json{ "name": "Pied Piper", "employeeCount": 10 }```@@ -133,7 +133,7 @@ Object contains column names and the desired values.```jssupabase.get("companies").match({ "name": "Pied Piper", "employeeCount": 10 })```-The following will be returned:+The following will be returned with status code `200 OK`:```json[{ "name": "Pied Piper", "employeeCount": 10 }@@ -144,7 +144,7 @@ The following will be returned:```jssupabase.get("companies").match({ "name": "Pied Piper", "employeeCount": 50 })```-The following will be returned:+The following will be returned with status code `200 OK`:```json[]```@@ -173,7 +173,7 @@ Value to match. Data type is dependent on the columnName specified.supabase.get("companies").eq("name", "Hooli")```-The following will be returned:+The following will be returned with status code `200 OK`:```json[{ "name": "Hooli", "employeeCount": 1000 }@@ -203,7 +203,7 @@ Value to compare to. Data type is dependent on the columnName specified.supabase.get("companies").gt("employeeCount", 10)```-The following will be returned:+The following will be returned with status code `200 OK`:```json[{ "name": "Hooli", "employeeCount": 1000 },@@ -234,7 +234,7 @@ Value to compare to. Data type is dependent on the columnName specified.supabase.get("companies").lt("employeeCount", "1000")```-The following will be returned:+The following will be returned with status code `200 OK`:```json[{ "name": "Pied Piper", "employeeCount": 10 },@@ -265,7 +265,7 @@ Value to compare to. Data type is dependent on the columnName specified.supabase.get("companies").gte("employeeCount", 10)```-The following will be returned:+The following will be returned with status code `200 OK`:```json[{ "name": "Pied Piper", "employeeCount": 10 },@@ -297,7 +297,7 @@ Value to compare to. Data type is dependent on the columnName specified.supabase.get("companies").lte("employeeCount", "1000")```-The following will be returned:+The following will be returned with status code `200 OK`:```json[{ "name": "Pied Piper", "employeeCount": 10 },@@ -329,7 +329,7 @@ String pattern to compare to. A comprehensive guide on how to form proper pattersupabase.get("companies").like("name", "%ao%")```-The following will be returned:+The following will be returned with status code `200 OK`:```json[{ "name": "Yao Net", "employeeCount": 100 }@@ -360,7 +360,7 @@ String pattern to compare to. A comprehensive guide on how to form patterns cansupabase.get("companies").like("name", "_pi%")```-The following will be returned:+The following will be returned with status code `200 OK`:```json[]```@@ -370,7 +370,7 @@ The following will be returned:supabase.get("companies").ilike("name", "_pi%")```-The following will be returned:+The following will be returned with status code `200 OK`:```json[{ "name": "Pied Piper", "employeeCount": 10}@@ -400,7 +400,7 @@ Value to match.supabase.get("companies").is("employeeCount", null)```-The following will be returned:+The following will be returned with status code `200 OK`:```json[{ "name": "See Food App", "employeeCount": null }@@ -430,7 +430,7 @@ Array of values to find a match. Data type of values is dependent on the columnNsupabase.get("companies").in("name", ["Hooli", "Pied Piper", "Google"])```-The following will be returned:+The following will be returned with status code `200 OK`:```json[{ "name": "Pied Piper", "employeeCount": 10 },@@ -461,7 +461,7 @@ Value to **not** match. Data type is dependent on the columnName specified.supabase.get("companies").not("name", "See Food App")```-The following will be returned:+The following will be returned with status code `200 OK`:```json[{ "name": "Pied Piper", "employeeCount": 10 },diff --git a/web/docs/library/restful/get.mdx b/web/docs/library/restful/get.mdxindex 224807f0a4e..ffc1b2ce4c3 100644--- a/web/docs/library/restful/get.mdx+++ b/web/docs/library/restful/get.mdx@@ -3,69 +3,166 @@ id: gettitle: 'Read Rows'----@todo short Description--## The basics+import Tabs from '@theme/Tabs';+import TabItem from '@theme/TabItem';++We will be using these tables as reference for our examples:+```json+{+ "users": [+ { "Id": 1, "fullName": "Richard Hendrix", "companyId": "Pied Piper" },+ { "Id": 2, "fullName": "Gavin Belson", "companyId": "Hooli" }+ ],+ "companies": [+ { "Id": 1, "name": "Pied Piper", "employeeCount": 10 },+ { "Id": 2, "name": "Hooli", "employeeCount": 1000 },+ { "Id": 3, "name": "Yao Net", "employeeCount": 100 },+ { "Id": 4, "name": "See Food App", "employeeCount": null }+ ],+}+```-@todo most simple usage+<Tabs+ defaultValue="nodeJs"+ values={[+ { label: 'Node.js', value: 'nodeJs', },+ { label: 'Python', value: 'py', },+ ]+}>+<TabItem value="nodeJs">+```js+supabase.get(tableName, options?)-## Examples+```+Given the `options?` set (if any), this **asynchronously** gets all rows from the specified `tableName` in your database.+</TabItem>-#### Query foreign tables+<TabItem value="py">-Get 5 open "todos" and the "users" that they belong to-```js-import { createClient } from '@supabase/supabase-js'--// Connect to Supabase-const base = createClient(process.env.SUPABASE_URL, {- apikey: process.env.SUPABASE_KEY-})--// Get a list of todos-const todos = await base- .get('todos')- .select(`- title,- details,- users { name, email }- `)- .eq('status', 'open')- .range(0, 5)+```py+# TODO```+</TabItem>+</Tabs>-#### Advanced filtering+## Method arguments+### tableName+`required` string+Name of table in the database that will be read from.-Get a user with the username 'kiwicopple'+### options+`optional` object+All available options and examples it their usage can be found [here](../restful/options).++## Additional filtering+### Select```js-import { createClient } from '@supabase/supabase-js'--// Connect to Supabase-const base = createClient(process.env.SUPABASE_URL, {- apikey: process.env.SUPABASE_KEY-})--// Get the user-const user = await base- .get('/users')- .match({ username: 'kiwicopple' })- .single()+select(columnArray)```+Returns an array of rows with only columns specified in `columnArray`.++#### Method arguments+##### columnArray+`required` array+```json+// From the 'users' table+[+ "Id",+ "fullName",+ "companyId"+]+```+Array of values representing column names found in the table. Typical data type would be string.+If a foreign key constraint exists between this table and another, information from+the other table can be requested as well. This is shown below:+```json+// From the 'users' table+[+ "fullName",+ {+ "companies": [+ "name",+ "employeeCount"+ ]+ }+]+```+Instead of a string data type, the column that has the foreign key constraint is now represented+as an object with the name of the other table as the key and the desired columns from the other+table as the value in the form of an array of column names of data type string.+##### Example+Click [here](../restful/get#using-select) view some examples.-## Options+### Common Filters+Other common filters can be found [here](../restful/filters).-| Parameter | Default | Description |-| --------- | ------- | ------------------------------------------- |-| @todo | | All options |+## Example-## Returns+### Generic+Get all companies and return all columns available+```js+supabase.get("companies")+```+The following will be returned with status code `200 OK`:+```json+[+ { "Id": 1, "name": "Pied Piper", "employeeCount": 10 },+ { "Id": 2, "name": "Hooli", "employeeCount": 1000 },+ { "Id": 3, "name": "Yao Net", "employeeCount": 100 },+ { "Id": 4, "name": "See Food App", "employeeCount": null }+]+```-#### 200: Success+### Using Select+Get all users but only return the column fullName.+```js+supabase.get("users").select(["fullName"])+```+The following will be returned with the status code `200 OK`:+```json+[+ { "fullName": "Richard Hendrix" },+ { "fullName": "Gavin Belson" }+]+```-@todo: all return scenarios+### Using Select with Foreign Key Constraints+Get all users and return all information about them and the companies they belong to.+```js+supabase.get("users").select([+ "fullName",+ {+ "companies": [+ "name",+ "employeeCount"+ ]+ }+])+```+The following will be returned with the status code `200 OK`:+```json+[+ {+ "fullName": "Richard Hendrix",+ "companies": {+ "name": "Pied Piper",+ "employeeCount": 10+ }+ },+ {+ "fullName": "Gavin Belson",+ "companies": {+ "name": "Hooli",+ "employeeCount": 1000+ }+ }+]+```+## Responses+Aside from the status code `200 OK`, other common responses can be found [here](../restful/responses).\ No newline at end of filediff --git a/web/docs/library/restful/post.mdx b/web/docs/library/restful/post.mdxindex 62f2d8f7a5e..787df6fc697 100644--- a/web/docs/library/restful/post.mdx+++ b/web/docs/library/restful/post.mdx@@ -19,7 +19,7 @@ import TabItem from '@theme/TabItem';supabase.post(tableName, data, options?)```-Given the `options?` set, this posts `data` into the selected `tableName` in your database.+Given the `options?` set (if any), this **asynchronously** posts `data` into the selected `tableName` in your database.</TabItem><TabItem value="py">@@ -100,8 +100,8 @@ const postUsers = async () => {.post("users",[- { name: "Richard Hendrix" },- { name: "Elrich Bachman" }+ { fullName: "Richard Hendrix" },+ { fullName: "Elrich Bachman" }],)return users@@ -128,8 +128,8 @@ The request has succeeded. New resource created will be returned:```json{"rows": [- { "name": "Richard Hendrix" },- { "name": "Elrich Bachman"}+ { "fullName": "Richard Hendrix" },+ { "fullName": "Elrich Bachman"}]}