© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•14mo ago•
2 replies
AndyJessop

Many-to-many Relation is not Detected

I have the following tables:
agents
agents
=>
uuid
uuid
, ...
channels
channels
=>
uuid
uuid
, ...
agent_channel
agent_channel
:
uuid
uuid
,
agent_uuid
agent_uuid
(fk),
channel_uuid
channel_uuid
(fk)

After following the docs on many-to-many joins here: https://supabase.com/docs/guides/database/joins-and-nesting?queryGroups=language&language=js#many-to-many-joins, I'm trying to select them like this:

const { data, error } = await this.#client
    .from("channels")
    .select("*,agents(*)")
    .order("created_at", { ascending: true });
const { data, error } = await this.#client
    .from("channels")
    .select("*,agents(*)")
    .order("created_at", { ascending: true });


But I get this error:

code:"PGRST200"
details:"Searched for a foreign key relationship between 'channels' and 'agents' in the schema 'public', but no matches were found."
hint:"Perhaps you meant 'agent_channel' instead of 'agents'."
message:"Could not find a relationship between 'channels' and 'agents' in the schema cache"
code:"PGRST200"
details:"Searched for a foreign key relationship between 'channels' and 'agents' in the schema 'public', but no matches were found."
hint:"Perhaps you meant 'agent_channel' instead of 'agents'."
message:"Could not find a relationship between 'channels' and 'agents' in the schema cache"


What am I doing wrong here? The only thing I can see is that it's a naming issue
id
id
vs
uuid
uuid
- is this a requirement?

Incidentally, the type inference is correct. If I hover
data
data
, I get this (which is correct):

const data: {
    created_at: string
    title: string     
    updated_at: string | null     
    uuid: string     
    agents: {         
        agent_type_uuid: string         
        created_at: string         
        display_name: string         
        system_prompt: string         
        updated_at: string | null         
        uuid: string     
    }[]
}[] | nul
const data: {
    created_at: string
    title: string     
    updated_at: string | null     
    uuid: string     
    agents: {         
        agent_type_uuid: string         
        created_at: string         
        display_name: string         
        system_prompt: string         
        updated_at: string | null         
        uuid: string     
    }[]
}[] | nul
Querying Joins and Nested tables | Supabase Docs
The Data APIs automatically detect relationships between Postgres tables.
Querying Joins and Nested tables | Supabase Docs
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

One To Many Relation, Dart Flutter, Database Swagger Codegen
SupabaseSSupabase / help-and-questions
4y ago
Apollo Client Graphql : limit to one row relation one-to-many
SupabaseSSupabase / help-and-questions
3y ago
relation does not exist
SupabaseSSupabase / help-and-questions
4y ago
RLS applying to many to many relationship
SupabaseSSupabase / help-and-questions
4y ago