© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
1 reply
Twisted Chaz

Typescript Type declaration on Inner Join?

I've got a query using the JS SDK that joins an inner table, but I'm not sure how I'm supposed to type it correctly.

albums_genres.album_id
albums_genres.album_id
has a squiggly and the error
Argument of type '"album_genres.album_id"' is not assignable to parameter of type 'keyof AlbumGenre'.ts(2345)
Argument of type '"album_genres.album_id"' is not assignable to parameter of type 'keyof AlbumGenre'.ts(2345)


const { data: genres, error } = await supabase
  .from<AlbumGenre>("genres")
  .select("id, genre, album_genres!inner( sub_genre )")
  .eq("album_genres.album_id", album_id);
const { data: genres, error } = await supabase
  .from<AlbumGenre>("genres")
  .select("id, genre, album_genres!inner( sub_genre )")
  .eq("album_genres.album_id", album_id);


and my current type is

type AlbumGenre = {
  id: number;
  genre: string;
  album_genres?: {
    album_id: number;
    genre_id: number;
    sub_genre: boolean;
  }[];
};
type AlbumGenre = {
  id: number;
  genre: string;
  album_genres?: {
    album_id: number;
    genre_id: number;
    sub_genre: boolean;
  }[];
};
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

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

inner join really slow
SupabaseSSupabase / help-and-questions
4y ago
Inner Join in Dart
SupabaseSSupabase / help-and-questions
4y ago
Filter inner joins
SupabaseSSupabase / help-and-questions
4y ago
Inner join not returning data
SupabaseSSupabase / help-and-questions
13mo ago