Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat: docs - add inferring type example (#21408)

hallidayo8934cd36c8fd
diff --git a/apps/docs/spec/supabase_js_v2.yml b/apps/docs/spec/supabase_js_v2.yml
index 17a50818b2c..1594bbf2544 100644
--- a/apps/docs/spec/supabase_js_v2.yml
+++ b/apps/docs/spec/supabase_js_v2.yml
@@ -1792,6 +1792,16 @@ functions:
from:sender_id(name),
to:receiver_id(name)
`)
+
+ // To infer types, use the name of the table (in this case `users`) and
+ // the name of the foreign key constraint.
+ const { data, error } = await supabase
+ .from('messages')
+ .select(`
+ content,
+ from:users!messages_sender_id_fkey(name),
+ to:users!messages_receiver_id_fkey(name)
+ `)
```
data:
sql: |