The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
docs: Update mentions of `foreign table` to `referenced table` (#18656)
Tyler831220c03e9f
diff --git a/apps/docs/docs/ref/javascript/typescript-support.mdx b/apps/docs/docs/ref/javascript/typescript-support.mdxindex dd555315a84..3bb119fd8be 100644--- a/apps/docs/docs/ref/javascript/typescript-support.mdx+++ b/apps/docs/docs/ref/javascript/typescript-support.mdx@@ -7,7 +7,7 @@ title: TypeScript SupportWith TypeScript, `supabase-js` detects things like `not null` constraints and [generated columns](https://www.postgresql.org/docs/current/ddl-generated-columns.html). Nullable columns are typed as `T | null` when you select the column. Generated columns will show a type error when you insert to it.-`supabase-js` also detects relationships between tables. A foreign table with one-to-many relationship is typed as `T[]`. Likewise, a foreign table with many-to-one relationship is typed as `T | null`.+`supabase-js` also detects relationships between tables. A referenced table with one-to-many relationship is typed as `T[]`. Likewise, a referenced table with many-to-one relationship is typed as `T | null`.## Generating typesdiff --git a/apps/studio/components/interfaces/Docs/Snippets.ts b/apps/studio/components/interfaces/Docs/Snippets.tsindex a6fb8f1ce7a..a52287458fc 100644--- a/apps/studio/components/interfaces/Docs/Snippets.ts+++ b/apps/studio/components/interfaces/Docs/Snippets.ts@@ -293,7 +293,7 @@ let { data: ${resourceId}, error } = await supabase},}),readForeignTables: (resourceId: string, endpoint: string, apiKey: string) => ({- title: 'Read foreign tables',+ title: 'Read referenced tables',bash: {language: 'bash',code: `diff --git a/apps/studio/components/interfaces/ProjectAPIDocs/ProjectAPIDocs.constants.ts b/apps/studio/components/interfaces/ProjectAPIDocs/ProjectAPIDocs.constants.tsindex 61ff28824c0..246776f8c60 100644--- a/apps/studio/components/interfaces/ProjectAPIDocs/ProjectAPIDocs.constants.ts+++ b/apps/studio/components/interfaces/ProjectAPIDocs/ProjectAPIDocs.constants.ts@@ -666,7 +666,7 @@ let { data: ${resourceId}, error } = await supabase},{key: 'read-foreign-tables',- title: 'Read foreign tables',+ title: 'Read referenced tables',bash: `curl '${endpoint}/rest/v1/${resourceId}?select=some_column,other_table(foreign_key)' \\-H "apikey: ${apikey}" \\diff --git a/apps/www/_blog/2022-08-24-building-a-realtime-trello-board-with-supabase-and-angular.mdx b/apps/www/_blog/2022-08-24-building-a-realtime-trello-board-with-supabase-and-angular.mdxindex c3888f6d2e3..82f13e1dda8 100644--- a/apps/www/_blog/2022-08-24-building-a-realtime-trello-board-with-supabase-and-angular.mdx+++ b/apps/www/_blog/2022-08-24-building-a-realtime-trello-board-with-supabase-and-angular.mdx@@ -682,7 +682,7 @@ Our first function will simplye insert an empty object into the `boards` table,Because we defined a default value for new rows in our SQL in the beginning, we don't have to pass any other data here.-To load all tables of a user could simply query the `user_boards` table, but we might want more information about the related board so we can also [query foreign tables](https://supabase.com/docs/reference/javascript/select#query-foreign-tables) to load the board information!+To load all tables of a user could simply query the `user_boards` table, but we might want more information about the related board so we can also [query referenced tables](https://supabase.com/docs/reference/javascript/select?example=query-referenced-tables) to load the board information!Go ahead and begin the **src/app/services/data.service.ts** with this:diff --git a/apps/www/_blog/2022-11-08-authentication-in-ionic-angular.mdx b/apps/www/_blog/2022-11-08-authentication-in-ionic-angular.mdxindex 0c52f3ba9d6..3b497cb2b54 100644--- a/apps/www/_blog/2022-11-08-authentication-in-ionic-angular.mdx+++ b/apps/www/_blog/2022-11-08-authentication-in-ionic-angular.mdx@@ -820,7 +820,7 @@ We already generated a service in the beginning, and here we can add the logic tCreating a group requires just a title, and we can gather the user ID from our authentication service to then call the `insert()` function from the Supabase client to create a new record that we then return to the caller.-When we want to get a list of groups, we can use `select()` but since we have a [foreign key that references the users table](https://supabase.com/docs/reference/javascript/select#query-foreign-tables), we need to join that information so instead of just having the `creator` field we end up getting the actual email for that ID instead!+When we want to get a list of groups, we can use `select()` but since we have a [foreign key that references the users table](https://supabase.com/docs/reference/javascript/select?example=query-referenced-tables), we need to join that information so instead of just having the `creator` field we end up getting the actual email for that ID instead!Go ahead now and start the **src/app/services/data.service.ts** like this:diff --git a/apps/www/_blog/2023-08-08-supabase-local-dev.mdx b/apps/www/_blog/2023-08-08-supabase-local-dev.mdxindex dd35dc32f28..5790e9c4626 100644--- a/apps/www/_blog/2023-08-08-supabase-local-dev.mdx+++ b/apps/www/_blog/2023-08-08-supabase-local-dev.mdx@@ -236,7 +236,7 @@ npx snaplet generate --sql > supabase/seed.sqlType generators introspect a PostgreSQL schema and automatically generate TypeScript definitions. This gives you [end-to-end type safety](https://www.youtube.com/watch?v=VSNgAIObBdw) from the database to the browser.-In the past month, we've added relationship detection in supabase-js. Foreign keys are now included in the generated types so that supabase-js can detect whether a foreign table should be an array (one-to-many) or an object (many-to-one). We've also added Helper Types to improve the developer experience for common scenarios, like short-hand accessors:+In the past month, we've added relationship detection in supabase-js. Foreign keys are now included in the generated types so that supabase-js can detect whether a referenced table should be an array (one-to-many) or an object (many-to-one). We've also added Helper Types to improve the developer experience for common scenarios, like short-hand accessors:```tsx// Beforediff --git a/apps/www/pages/beta.tsx b/apps/www/pages/beta.tsxindex 409fd04210f..c4d571da255 100644--- a/apps/www/pages/beta.tsx+++ b/apps/www/pages/beta.tsx@@ -587,7 +587,7 @@ const NewFeaturesAndIntegrations = () => {You can use your database immediately, without an ORM or an API backend. Wesupport GraphQL-like{' '}<a- href="/docs/reference/javascript/select#query-foreign-tables"+ href="/docs/reference/javascript/select?example=query-referenced-tables"target="_blank"className="text-brand hover:text-brand">diff --git a/spec/examples/examples.yml b/spec/examples/examples.ymlindex 37272f797b2..bac575211da 100644--- a/spec/examples/examples.yml+++ b/spec/examples/examples.yml@@ -842,7 +842,7 @@ functions:}hideCodeBlock: true- id: query-foreign-tables- name: Query foreign tables+ name: Query referenced tablesdescription: |If your database has foreign key relationships, you can query related tables too.code: |@@ -917,7 +917,7 @@ functions:}- id: query-foreign-tables-through-a-join-table- name: Query foreign tables through a join table+ name: Query referenced tables through a join tabledata:sql: |create table@@ -998,9 +998,9 @@ functions:`)```- id: query-the-same-foreign-table-multiple-times- name: Query the same foreign table multiple times+ name: Query the same referenced table multiple timesdescription: |- If you need to query the same foreign table twice, use the name of the+ If you need to query the same referenced table twice, use the name of thejoined column to identify which join to use. You can also give eachcolumn an alias.@@ -1068,9 +1068,9 @@ functions:</Tabs>hideCodeBlock: true- id: filtering-through-foreign-tables- name: Filtering through foreign tables+ name: Filtering through referenced tablesdescription: |- If the filter on a foreign table's column is not satisfied, the foreign+ If the filter on a referenced table's column is not satisfied, the referencedtable returns `[]` or `null` but the parent table is not filtered out.<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">@@ -2206,9 +2206,9 @@ functions:</TabPanel></Tabs>- ### Filter Foreign Tables+ ### Filter Referenced Tables- You can filter on foreign tables in your `select()` query using dot+ You can filter on referenced tables in your `select()` query using dotnotation:<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">@@ -4005,7 +4005,7 @@ functions:</Tabs>hideCodeBlock: true- id: use`or`on-foreign-tables- name: Use `or` on foreign tables+ name: Use `or` on referenced tablesdescription: |<Tabs scrollable size="small" type="underlined" defaultActiveId="schema"><TabPanel id="schema" label="Schema">@@ -4137,7 +4137,7 @@ functions:.filter('name', 'in', '("Algeria","Japan")')```- id: on-a-foreign-table- name: On a foreign table+ name: On a referenced tabledescription: |<Tabs scrollable size="small" type="underlined" defaultActiveId="schema"><TabPanel id="schema" label="Schema">@@ -4373,9 +4373,9 @@ functions:.order('id', { ascending: false })```- id: on-a-foreign-table- name: On a foreign table+ name: On a referenced tabledescription: |- Ordering on foreign tables doesn't affect the ordering of+ Ordering on referenced tables doesn't affect the ordering ofthe parent table.<Tabs scrollable size="small" type="underlined" defaultActiveId="schema">@@ -4507,7 +4507,7 @@ functions:.limit(1)```- id: on-a-foreign-table- name: On a foreign table+ name: On a referenced tabledescription: |<Tabs scrollable size="small" type="underlined" defaultActiveId="schema"><TabPanel id="schema" label="Schema">diff --git a/spec/supabase_js_v2.yml b/spec/supabase_js_v2.ymlindex 173269b3913..ca55f330ea3 100644--- a/spec/supabase_js_v2.yml+++ b/spec/supabase_js_v2.yml@@ -1337,8 +1337,8 @@ functions:"statusText": "OK"}```- - id: query-foreign-tables- name: Query foreign tables+ - id: query-referenced-tables+ name: Query referenced tablesdescription: |If your database has foreign key relationships, you can query related tables too.code: |@@ -1400,18 +1400,18 @@ functions:"statusText": "OK"}```- - id: query-foreign-tables-through-a-join-table- name: Query foreign tables through a join table+ - id: query-referenced-tables-through-a-join-table+ name: Query referenced tables through a join tablecode: |```ts- const { data, error } = await supabase- .from('users')- .select(`- name,- teams (- name- )- `)+ const { data, error } = await supabase+ .from('users')+ .select(`+ name,+ teams (+ name+ )+ `)```data:sql: |@@ -1486,8 +1486,8 @@ functions:the `select()` method to query the related data. The join table needsto have the foreign keys as part of its composite primary key.hideCodeBlock: true- - id: query-the-same-foreign-table-multiple-times- name: Query the same foreign table multiple times+ - id: query-the-same-referenced-table-multiple-times+ name: Query the same referenced table multiple timescode: |```tsconst { data, error } = await supabase@@ -1541,12 +1541,12 @@ functions:}```description: |- If you need to query the same foreign table twice, use the name of the+ If you need to query the same referenced table twice, use the name of thejoined column to identify which join to use. You can also give eachcolumn an alias.hideCodeBlock: true- - id: filtering-through-foreign-tables- name: Filtering through foreign tables+ - id: filtering-through-referenced-tables+ name: Filtering through referenced tablescode: |```tsconst { data, error } = await supabase@@ -1595,12 +1595,12 @@ functions:}```description: |- If the filter on a foreign table's column is not satisfied, the foreign+ If the filter on a referenced table's column is not satisfied, the referencedtable returns `[]` or `null` but the parent table is not filtered out.If you want to filter out the parent table rows, use the `!inner` hinthideCodeBlock: true- - id: querying-foreign-table-with-count- name: Querying foreign table with count+ - id: querying-referenced-table-with-count+ name: Querying referenced table with countcode: |```tsconst { data, error } = await supabase@@ -1728,8 +1728,8 @@ functions:[operators](/docs/guides/database/json#query-the-jsonb-data) forquerying JSON data.hideCodeBlock: true- - id: querying-foreign-table-with-inner-join- name: Querying foreign table with inner join+ - id: querying-referenced-table-with-inner-join+ name: Querying referenced table with inner joincode: |```tsconst { data, error } = await supabase@@ -1775,7 +1775,7 @@ functions:}```description: |- If you don't want to return the foreign table contents, you can leave the parenthesis empty.+ If you don't want to return the referenced table contents, you can leave the parenthesis empty.Like `.select('name, countries!inner()')`.hideCodeBlock: true@@ -2414,8 +2414,8 @@ functions:"statusText": "OK"}```- - id: filter-foreign-tables- name: Filter Foreign Tables+ - id: filter-referenced-tables+ name: Filter referenced tablescode: |```tsconst { data, error } = await supabase@@ -2469,7 +2469,7 @@ functions:}```description: |- You can filter on foreign tables in your `select()` query using dot+ You can filter on referenced tables in your `select()` query using dotnotation.######## TODO CHECK FILTER YAML ERRORS ########- id: eq@@ -3740,8 +3740,8 @@ functions:}```hideCodeBlock: true- - id: use-or-on-foreign-tables- name: Use `or` on foreign tables+ - id: use-or-on-referenced-tables+ name: Use `or` on referenced tablescode: |```tsconst { data, error } = await supabase@@ -3752,7 +3752,7 @@ functions:name)`)- .or('country_id.eq.1,name.eq.Beijing', { foreignTable: 'cities' })+ .or('country_id.eq.1,name.eq.Beijing', { referenceTable: 'cities' })```data:sql: |@@ -3844,8 +3844,8 @@ functions:```hideCodeBlock: trueisSpotlight: true- - id: on-a-foreign-table- name: On a foreign table+ - id: on-a-referenced-table+ name: On a referenced tablecode: |```tsconst { data, error } = await supabase@@ -3999,8 +3999,8 @@ functions:```hideCodeBlock: trueisSpotlight: true- - id: on-a-foreign-table- name: On a foreign table+ - id: on-a-referenced-table+ name: On a referenced tablecode: |```tsconst { data, error } = await supabase@@ -4011,7 +4011,7 @@ functions:name)`)- .order('name', { foreignTable: 'cities', ascending: false })+ .order('name', { referenceTable: 'cities', ascending: false })```data:sql: |@@ -4061,7 +4061,7 @@ functions:}```description: |- Ordering on foreign tables doesn't affect the ordering of+ Ordering on referenced tables doesn't affect the ordering ofthe parent table.hideCodeBlock: true@@ -4105,8 +4105,8 @@ functions:```hideCodeBlock: trueisSpotlight: true- - id: on-a-foreign-table- name: On a foreign table+ - id: on-a-referenced-table+ name: On a referenced tablecode: |```tsconst { data, error } = await supabase@@ -4117,7 +4117,7 @@ functions:name)`)- .limit(1, { foreignTable: 'cities' })+ .limit(1, { referenceTable: 'cities' })```data:sql: |