mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
docs(api): note db.schema generic requirement for TS (#49967)
Adds a note to the "Using Custom Schemas" guide:
`createClient<Database>(...)` needs the schema passed as the second
generic (`createClient<Database, 'myschema'>(...)`) to type-check
`db.schema` against anything but `public`.
`supabase.schema('myschema').from(...)` is the per-call alternative that
needs no second generic.
Related to supabase/supabase-js#969 — the existing JS example has no
type parameters so it never surfaces this, and TypeScript users
extending it with `<Database>` hit a confusing compile error with no
pointer to the fix.
supabase-js companion: supabase/supabase-js#2662
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Documentation**
* Added guidance to the custom schemas guide explaining TypeScript
typing behavior when using non-public schemas.
* Clarified how to specify a schema explicitly and when schema types are
inferred automatically.
* Noted that custom schemas must be included in the generated `Database`
type.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
1 parent
95ca302439
commit
bdfd69e955
1 file changed
+6
@@ -56,6 +56,12 @@ const { data: todos, error } = await supabase.from('todos').select('*')
|
||||
const { data: todos, error } = await supabase.schema('myschema').from('todos').select('*')
|
||||
```
|
||||
|
||||
<Admonition type="note">
|
||||
|
||||
With generated `Database` types that include `public`, `createClient<Database>(...)` type-checks `db.schema` against `public` only, unless the schema name is also passed as the second generic: `createClient<Database, 'myschema'>(...)`. `supabase.schema('myschema').from(...)` infers its schema per call and needs no second generic. In both cases `myschema` has to be present in the generated `Database` type.
|
||||
|
||||
</Admonition>
|
||||
|
||||
</TabPanel>
|
||||
<$Show if="sdk:dart">
|
||||
<TabPanel id="dart" label="Dart">
|
||||
|
||||
Reference in new issue
Block a user