docs(supabase-js): add example to clarify how to fetch data with spaces in table name (#33443)

* docs: add supabase-js example with spaces in table names

* update copy and example
This commit is contained in:
Teng Wei Herr authored and Joshen Lim committed 2025-03-05 15:39:01 +01:00
1 parent 589bac6751
commit 6fa2874a9f
1 file changed
+63
+63
View File
@@ -3223,6 +3223,69 @@ functions:
"statusText": "OK"
}
```
- id: query-referenced-tables-with-spaces-in-their-names
name: Query referenced tables with spaces in their names
description: |
If your table name contains spaces, you must use double quotes in the `select` statement to reference the table.
code: |
```js
const { data, error } = await supabase
.from('orchestal sections')
.select(`
name,
"musical instruments" (
name
)
`)
```
data:
sql: |
```sql
create table
"orchestral sections" (id int8 primary key, name text);
create table
"musical instruments" (
id int8 primary key,
section_id int8 not null references "orchestral sections",
name text
);
insert into
"orchestral sections" (id, name)
values
(1, 'strings'),
(2, 'woodwinds');
insert into
"musical instruments" (id, section_id, name)
values
(1, 2, 'flute'),
(2, 1, 'violin');
```
response: |
```json
{
"data": [
{
"name": "strings",
"musical instruments": [
{
"name": "violin"
}
]
},
{
"name": "woodwinds",
"musical instruments": [
{
"name": "flute"
}
]
}
],
"status": 200,
"statusText": "OK"
}
```
- id: query-referenced-tables-through-a-join-table
name: Query referenced tables through a join table
code: |